This one has been bothering me for a while now,
How should we store a value in a set or map in a for loop?
(let [s #{}]
(for [ i (range 10)
j (range 10) ]
(into s [i j])))
i know this will not work, but i want a functionality similar to this , where the set will finally contain [0 0] [0 1]…[0 9] [1 0]…[9 9]
Thanks
If I understand your question correctly you need to turn your expression inside-out:
The thing to realize here is that
forreturns a value (a lazy sequence) unlike for-loops in more imperative languages like Java and C.