The problem is probably on the else clause of accum-if-satisfies
, should be just acc
not (acc)
.
You could use filter
and then map
instead of reduce
. Like that:
(map #(first %)
(filter #(p (second %))
(zip-with-index coll)))
You could also call map-indexed
with vector
instead of (fn [i c] [i c])
.
The whole code would look like that:
(defn indexes-satisfying
[p coll]
(map #(first %)
(filter #(p (second %))
(map-indexed vector coll))))