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] (defmacro ap-map [form lst]
"Yield elements evaluated in the form for each element in the list." "Yield elements evaluated in the form for each element in the list."
`(let [[f (lambda [it] ~form)]] (let [[v (gensym 'v)] [f (gensym 'f)]]
(for [v ~lst] `(let [[~f (lambda [it] ~form)]]
(yield (f v))))) (for [~v ~lst]
(yield (~f ~v))))))
(defmacro ap-map-when [predfn rep lst] (defmacro ap-map-when [predfn rep lst]

View File

@ -54,7 +54,9 @@
(assert-equal (list (ap-map (* it 3) [1 2 3])) (assert-equal (list (ap-map (* it 3) [1 2 3]))
[3 6 9]) [3 6 9])
(assert-equal (list (ap-map (* it 3) [])) (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 [] (defn test-ap-map-when []
"NATIVE: testing anaphoric map-when" "NATIVE: testing anaphoric map-when"