I would like to iterate over a collection and at the same time also maintain a counter ex
(for [x (range 10) y (inc 0)] [x y] )
I would like ‘y’ to represent the counter, so for every element the output is ( [0 0] [ 1 1] [2 2]…). How do I do that?
You can use
indexedfromclojure.contrib.seq. Example:You can also use
map-indexed. Example: