I suggest that if this question was still not marked as โansweredโ, there might be something else you are looking for, and perhaps this is the flexibility to define your own counter.
I agree with others that map-indexed
is the way to go for the specific problem you have outlined. However, if you insist on using for
, I would recommend something like this:
(for [[xy] (map vector (range 10) (iterate inc 0))] [xy])
Rafal has a very similar answer, except that the counter will always start at zero and increment by 1. In my version you can define your counter as you see fit. For example, changing the above (iterate inc 0)
to (iterate #(+ 2 %) 10)
, instead you can have a counter that starts at 10 and increments by 2.
source share