Skip to content

Instantly share code, notes, and snippets.

@deltam
Created May 3, 2012 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deltam/2584539 to your computer and use it in GitHub Desktop.
Save deltam/2584539 to your computer and use it in GitHub Desktop.
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
Copy link

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