Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

bob bae http://sparebandwidth.blogspot.com

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

car cdr cons from little LISPer

// description of your code here

(define cons
 (lambda (u v)
   (lambda (b)
     (cond (b u)
     (#t v)))))
(define lunch (cons 'apple '()))
(define car (lambda (l) (l #t)))
(define cdr (lambda (l) (l #f)))


the applicative-order Y-combinator

// description of your code here

(define Y
  (lambda (f)
    (let ((future
            (lambda (future)
              (f (lambda (arg) 
                   ((future future) arg))))))
      (future future))))

((Y (lambda (factorial)
      (lambda (n)
        (if (= n 0)
            1
            (* n (factorial (- n 1)))))))
 42)
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS