#include <stdio.h>
#include "list.h"

struct item *list_reverse(struct item *curr)
{
    struct item *prev, *next;
    for (prev = NULL; curr; prev = curr, curr = next) {
        next = curr->next;
        curr->next = prev;
    }
    return prev;
}

struct item *list_reverse1(struct item *p)
{
    struct item *rev;
    if (!p || !p->next)
        return p;
    rev = list_reverse1(p->next);
    p->next->next = p;
    p->next = NULL;
    return rev;
}

int main()
{
    struct item *p = NULL;

    list_push(&p, 4);
    list_push(&p, 3);
    list_push(&p, 2);
    list_push(&p, 1);

    list_print(p);
    struct item *rev = list_reverse1(p);
    list_print(rev);

    return 0;
}
