previous | index | next

Simulating cons

To cons an integer onto a list lst, we must:
  list cons(int i, list lst) {
      list newItem = new listItem;
      newItem->item = i;
      newItem->rest = lst;
      return newItem;
  }

previous | index | next