sicp

sicp sandbox.
git clone git://git.ricketyspace.net/sicp.git
Log | Files | Refs

commit c56eecd98a88ca6e1f7f625191f6164847b24829
parent 42c02f0e4750523a53e0e7ada3661100f051edde
Author: rsiddharth <s@ricketyspace.net>
Date:   Sat, 14 Jul 2018 17:06:08 +0000

Add (net ricketyspace sicp two six).

* net/ricketyspace/sicp/two/six.scm: New file.

Diffstat:
net/ricketyspace/sicp/two/six.scm | 23+++++++++++++++++++++++
1 file changed, 23 insertions(+), 0 deletions(-)

diff --git a/net/ricketyspace/sicp/two/six.scm b/net/ricketyspace/sicp/two/six.scm @@ -0,0 +1,23 @@ +;;;; Under Creative Commons Attribution-ShareAlike 4.0 +;;;; International. See +;;;; <https://creativecommons.org/licenses/by-sa/4.0/>. + +;;; Reference: http://enwp.org/?title=Church_encoding&oldid=849484371 + +(define-module (net ricketyspace sicp two six) + #:export (zero + add-1 + one + two + plus)) + +(define zero (lambda (f) (lambda (x) x))) + +(define (add-1 n) + (lambda (f) (lambda (x) (f ((n f) x))))) + +(define one (lambda (f) (lambda (x) (f x)))) +(define two (lambda (f) (lambda (x) (f (f x))))) + +(define (plus m n) + (lambda (f) (lambda (x) ((m f) ((n f) x)))))