#include #include #include "list.h" struct list { OBJTYPE value; list* next; }; list* nil() { return NULL; } list* cons(OBJTYPE h, list* t) { list* n = (list*)malloc(sizeof(list)); if (!n) { fprintf(stderr,"Malloc failed, world ended\n"); exit(1); } n->next = t; n->value = h; return n; } int is_nil(list* l) { return (l == NULL); } OBJTYPE head(list* l) { return l->value; } list* tail(list* l) { return l->next; } void print_list(list* l) { if (l == NULL) { return; } printf("%d\n",l->value); print_list(l->next); } void release(list* l) { if (l == NULL) { return; } release(l->next); free(l); }