proper lexical scoping now woo
This commit is contained in:
parent
ce9489b5d2
commit
27df5f8ce0
13 changed files with 349 additions and 45 deletions
19
examples/map.scm
Normal file
19
examples/map.scm
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
(def defn
|
||||
(mac (name args . body)
|
||||
(list 'def name (cons 'fn (cons args body)))))
|
||||
|
||||
(defn map-aux (f acc l)
|
||||
(if (nil? l)
|
||||
(acc f '())
|
||||
(map-aux
|
||||
f
|
||||
(fn (f ys)
|
||||
(acc f (cons (f (head l)) ys)))
|
||||
(tail l))))
|
||||
|
||||
(defn map (f l)
|
||||
(map-aux f (fn (f x) x) l))
|
||||
|
||||
(println
|
||||
(map (fn (x) (* x x))
|
||||
'(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue