/* * File: * ilist.c * Authors: * CSC195 2003S * Summary: * Implementation of important stuff related to * Scheme-like lists of integers. */ #include "ilist.h" /* Simple wrapper for clarity. */ ilist inull() { return (ilist) NULL; } /* inull() */ int iIsEmpty(ilist il) { return (il == (ilist) NULL); } /* iIsEmpty(ilist) */ /* May return null if there's not enough space in memory for a new pair. */ ilist icons(int head, ilist tail) { ilist newlist = (ilist) malloc(sizeof(inode)); if (!newlist) return newlist; newlist->val = head; newlist->next = tail; return newlist; } /* incons(int, ilist) */ int icar(ilist il) { /* Error checking? */ return ilist->val; } ilist icdr(ilist il) { return ilist->next; }