fixed ap-map potential naming conflict
This commit is contained in:
parent
a76c3d1f51
commit
0195de6545
@ -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]
|
||||||
|
@ -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"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user