################## # # Pair (Lisp S-Node) # A lisp "Pair" contains a left and a right. # Left may be anything, but right must always be another Pair, or null. p7class Pair { (tcl)left (Pair)right } # "cons" allocates a new Pair with its two parameters p7proc (Pair)cons { (tcl)a (Pair)b } { set (Pair)z [new (Pair)] set z(left) $a set z(right) $b set z } # "hd" gets the left slot p7proc (tcl)hd { (Pair)x } { k $x(left) } # "tl" gets the right slot p7proc (Pair)tl { (Pair)x } { k $x(right) }