proper lexical scoping now woo
This commit is contained in:
parent
ce9489b5d2
commit
27df5f8ce0
13 changed files with 349 additions and 45 deletions
22
examples/fizzbuzz.scm
Normal file
22
examples/fizzbuzz.scm
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(def each-integer-aux
|
||||
(fn (n i thunk)
|
||||
(if (= n 0)
|
||||
'()
|
||||
(progn
|
||||
(thunk (- (+ i 1) n))
|
||||
(each-integer-aux (- n 1) i thunk)))))
|
||||
|
||||
(def each-integer
|
||||
(fn (n thunk)
|
||||
(each-integer-aux n n thunk)))
|
||||
|
||||
(each-integer 30
|
||||
(fn (x)
|
||||
(if (or (= 0 (% x 3)) (= 0 (% x 5)))
|
||||
(progn
|
||||
(if (= 0 (% x 3))
|
||||
(write "Fizz"))
|
||||
(if (= 0 (% x 5))
|
||||
(write "Buzz")))
|
||||
(print x))
|
||||
(write "\n")))
|
||||
Loading…
Add table
Add a link
Reference in a new issue