clojure 2026-08-25

I feel it would be nice if for/doseq had a :iter-count i directive as well where i would now be bound to the iteration count.

➕ 2

Make an ask for it? (Gets rejected for use map-indexed vector)

➕ 1
🤣 1

They'd probably reject asking for a :do-while as well ? So you can stop before pulling 1 more element

That can be an in house macro, there is more rationale in asking for the iter count because it could be a primitive binding

For & doseq already have :while (https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/for) As for iteration counting, hmmmm.... how would it interact with multiple levels and :when?

:do-while is niche, but it's likely less controversial. It has a more straightforward path to prevent taking one more than necessary. It's called :iter-count and then you bind to whatever symbol you want, I used i in my example, but I was assuming it would be the iteration count. It's true nesting is a bit more tricky, I'm guessing you could repeat it multiple times and bind different symbols so you can get the iteration count at each nesting if you want.

> repeat it multiple times and bind different symbols so you can get the iteration count at each nesting if you want On paper it sounds very interesting and I don't think there's a combination of things you could do inside for/`doseq` to achieve that. But it will also probably get countered with "what practical problem does it solve" if you were to create an Ask. :D

Ya, the use-case is that map-indexed is gnarly both in syntax verbosity and in creating intermediate sequences and vectors. Which I feel they'll likely reject

You still wouldn't be able to get the iteration count on loopr correct? You can have your own accumulator for it but it's not counting per-nesting level

I've always been grimly happy with the old "(map-indexed vector ...)" trick.

I once wrote https://github.com/nathell/clj-iter that allows for this, but haven’t felt the need for it in like 16 years (omg time flies) :)

I just find that one in the comments of the LOOPR article and was looking into it haha