Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

And here it is in Racket or Scheme:

    (define (apply a b)
      (cond ((null? a) (list b))
            ((procedure? a) (cons (car a) b))
            ((null? (car a)) (cdr a))
            ((procedure? (car a)) (apply (apply (caar a) b) (apply (cdr a) b)))
            ((null? b) (caar a))
            ((procedure? b) (apply (cdar a) (car b)))
            (else (apply (apply (cdr a) (car b)) (cdr b)))))
    
    (define t-false null)
    (define t-true (list null))
    (define t-not (cons (cons (list null) (cons null null)) null))
    
    (apply t-not t-false)
    (apply t-not t-true)
Leaf is null, Stem is list and Fork is cons.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: