Implementing a counter in for
clojure, for-loop
Solution
You can use `indexed` from `clojure.contrib.seq`. Example:
(indexed '(a b c d)) => ([0 a] [1 b] [2 c] [3 d])
You can also use `map-indexed`. Example:
(map-indexed vector "foobar") => ([0 \f] [1 \o] [2 \o] [3 \b] [4 \a] [5 \r])
Problem
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?