new cons := lambda a { ret := lambda b {
  ret := lambda code {
    if (code = 0) { ret := a; }
    if (code = 1) { ret := b; }
    if (code = 2) { ret := true; } # for the "iscons" function
  };
};};

new car := lambda c { ret := c(0); };
new cdr := lambda c { ret := c(1); };

# nil is the empty list.
new nil := lambda code {
  if (code = 2) { ret := false; }
  else { ret := 1/0; } # This is like throwing an exception in a dirty way.
};

new iscons := lambda c { ret := c(2); };
new isnil := lambda c { ret := not c(2); };

new print_list := lambda L {
  if (iscons(L)) {
    write car(L);
    print_list(cdr(L));
  }
};

print_list( cons(1)(cons(2)(cons(3)(nil))) );