next up previous contents
Next: Subtracting a number: `sub' Up: Extended Numerical Abstractions Previous: Abstraction `zeropair'   Contents


Decrementing a number: `pred'

This abstraction determines the predecessor of a natural number, which corresponds to decrementing it.

(define pred  (lambda (n) 
                (cdr ((n (lambda (x) 
                           (cons (add (car x) one)
                                 (car x))))
                      zeropair))))


(ndisp! (pred one))
                             --> 0
(ndisp! (pred three))
                             --> 2



Georg P. Loczewski 2004-03-05


Impressum und Datenschutz