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


Decrementing a number: `pred'

This abstraction determines the predecessor of a natural number, which corresponds to decrementing it.
\begin{lstlisting}[language=Scm]{}
(define pred (lambda (n)
(cdr ((n (lambda (x)
(cons (add (car x) one)
(car x))))
zeropair))))
\end{lstlisting}

\begin{lstlisting}[language=Scm]{}
(ndisp! (pred one))
--> 0
(ndisp! (pred three))
--> 2
\end{lstlisting}



domain access counter Georg P. Loczewski 2004-03-05