From c56eecd98a88ca6e1f7f625191f6164847b24829 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 14 Jul 2018 17:06:08 +0000 Subject: Add (net ricketyspace sicp two six). * net/ricketyspace/sicp/two/six.scm: New file. --- net/ricketyspace/sicp/two/six.scm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 net/ricketyspace/sicp/two/six.scm (limited to 'net/ricketyspace') diff --git a/net/ricketyspace/sicp/two/six.scm b/net/ricketyspace/sicp/two/six.scm new file mode 100644 index 0000000..62f6d17 --- /dev/null +++ b/net/ricketyspace/sicp/two/six.scm @@ -0,0 +1,23 @@ +;;;; Under Creative Commons Attribution-ShareAlike 4.0 +;;;; International. See +;;;; . + +;;; 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))))) -- cgit v1.2.3