Created
May 3, 2012 09:10
1 + 1 on zozotez http://code.google.com/p/zozotez/ #残パン会
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; print 1 + 1 | |
; usage: ./zozotez test.zzz | |
(p | |
(? (: 'sum (\ (x y) (? x (sum (d x) (c (a x) y)) y))) | |
(? (: 'leq (\ (x y) (? x (? y (leq (d x) (d y)) NIL) (? y NIL T)))) | |
(? (: 'find (\ (x n) (? (leq x (e (a n))) (a n) (? n (find x (d n)) NIL)))) | |
(? (: '1 '(a)) | |
(? (: '2 '(a a)) | |
(? (: '3 '(a a a)) | |
(? (: '4 '(a a a a)) | |
(? (: '5 '(a a a a a)) | |
(? (: '6 '(a a a a a a)) | |
(? (: '7 '(a a a a a a a)) | |
(? (: '8 '(a a a a a a a a)) | |
(? (: '9 '(a a a a a a a a a)) | |
(? (: 'nums '(1 2 3 4 5 6 7 8 9)) | |
(find (sum 1 1) nums) | |
))))))))))))) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
;; looks better without the if-clauses.
;; I've wrapped the whole thing in one anonymous lambda that is executed
((\ ()
(: 'sum (\ (x y) (? x (sum (d x) (c (a x) y)) y)))
(: 'leq (\ (x y) (? x (? y (leq (d x) (d y)) NIL) (? y NIL T))))
(: 'find (\ (x n) (? (leq x (e (a n))) (a n) (? n (find x (d n)) NIL))))
(: '1 '(a))
(: '2 '(a a))
(: '3 '(a a a))
(: '4 '(a a a a))
(: '5 '(a a a a a))
(: '6 '(a a a a a a))
(: '7 '(a a a a a a a))
(: '8 '(a a a a a a a a))
(: '9 '(a a a a a a a a a))
(: 'nums '(1 2 3 4 5 6 7 8 9))
(: 'list (\ l l))
(p (list '|1 + 1 = | (find (sum 1 1) nums)) NIL)))