git @ Cat's Eye Technologies Argyle / master eg / cons-list.argyle
master

Tree @master (Download .tar.gz)

cons-list.argyle @masterraw · history · blame

;
; The second (and successful!) attempt to implement cons lists in ABTs
; by representing them with ABT application nodes.
;
(let ((cons
        (lambda (x y)
          (subst (subst (stencil (x y) (x y)) "x" (abt x)) "y" (abt y))))
      (car
        (lambda (lst)
          (destruct-abt lst
            (lambda (name) (neg 1))
            (lambda (val) (neg 2))
            (lambda (param body) (neg 3))
            (lambda (name expr body) (neg 4))
            (lambda (fn arg) (eval fn))
            (lambda (name arg) (neg 6)))))
      (cdr
        (lambda (lst)
          (destruct-abt lst
            (lambda (name) (neg 1))
            (lambda (val) (neg 2))
            (lambda (param body) (neg 3))
            (lambda (name expr body) (neg 4))
            (lambda (fn arg) (eval arg))
            (lambda (name arg) (neg 6)))))
      (lst (cons 1 (cons 2 (cons 3 0)))))
        (car (cdr lst)))