fixed ap-map potential naming conflict

This commit is contained in:
maresp 2014-04-18 02:45:05 +02:00
parent a76c3d1f51
commit 0195de6545
2 changed files with 7 additions and 4 deletions

View File

@ -46,9 +46,10 @@
(defmacro ap-map [form lst]
"Yield elements evaluated in the form for each element in the list."
`(let [[f (lambda [it] ~form)]]
(for [v ~lst]
(yield (f v)))))
(let [[v (gensym 'v)] [f (gensym 'f)]]
`(let [[~f (lambda [it] ~form)]]
(for [~v ~lst]
(yield (~f ~v))))))
(defmacro ap-map-when [predfn rep lst]

View File

@ -54,7 +54,9 @@
(assert-equal (list (ap-map (* it 3) [1 2 3]))
[3 6 9])
(assert-equal (list (ap-map (* it 3) []))
[]))
[])
(assert-equal (let [[v 1] [f 1]] (list (ap-map (it v f) [(fn [a b] (+ a b))])))
[2]))
(defn test-ap-map-when []
"NATIVE: testing anaphoric map-when"