next up previous contents index
Next: Initializing the A++ Interpreter Up: Initializing the A++ Interpreter Previous: Initializing the A++ Interpreter   Contents   Start

Initializing the A++ Interpreter part 3



(define compose (lambda (f g)
                  (lambda (x) 
                    (f (g x)))))
(define add    (lambda (m n)
                 (lambda (f) 
                   (compose (m f) (n f)))))
(define succ   (lambda (n) 
                 (lambda (f) 
                   (compose  f (n f)))))
(define mult   (lambda (m n)
                 (compose m n)))
(define length (lambda (l) 
                 (if (nullp l) 
                     zero
                     (add one (length (cdr l))))))
(define zeropair (cons zero zero))
(define pred   (lambda (n) 
                 (cdr ((n (lambda (x) 
                            (cons (add (car x) one)
                                  (car x))))
                       zeropair))))
(define sub    (lambda (m n)
                 ((n pred) m)))
;



Georg P. Loczewski 2004-03-05


Impressum und Datenschutz