Skip to content

Instantly share code, notes, and snippets.

@deltam

deltam/test.zzz

Created May 3, 2012
Embed
What would you like to do?
1 + 1 on zozotez http://code.google.com/p/zozotez/ #残パン会
; 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)
)))))))))))))
)
@westerp

This comment has been minimized.

Copy link

@westerp westerp commented Apr 11, 2013

;; 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)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.