summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2018-07-14 17:06:08 +0000
committerrsiddharth <s@ricketyspace.net>2018-07-14 17:06:08 +0000
commitc56eecd98a88ca6e1f7f625191f6164847b24829 (patch)
tree45143a37346c8baada8f518f4f9126ef95901137
parent42c02f0e4750523a53e0e7ada3661100f051edde (diff)
Add (net ricketyspace sicp two six).
* net/ricketyspace/sicp/two/six.scm: New file.
-rw-r--r--net/ricketyspace/sicp/two/six.scm23
1 files changed, 23 insertions, 0 deletions
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
+;;;; <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)))))