/*
 * File:
 *   slist.c
 * Authors:
 *   CSC195 2003S
 * Summary:
 *   Implementation of important stuff related to
 *   Scheme-like lists.
 */

#include "slist.h"

/* Simple wrapper for clarity. */
slist 
null() {
  return (slist) NULL;
} /* null() */

int 
isEmpty(slist lst) {
  return (lst == (slist) NULL);
} /* isEmpty(slist) */

/* May return null if there's not enough space in
   memory for a new pair. */
slist 
cons(void *head, slist talst) {
  slist newlist = (slist) malloc(sizeof(inode));
  if (!newlist) return newlist;
  newlist->val = head;
  newlist->next = talst;
  return newlist;
} /* cons(int, slist) */

void *
car(slist lst) {
  /* Error checking? */
  return lst->val;
} /* car(slist) */

slist 
cdr(slist lst) {
  return lst->next;
} /* cdr(slist) */
