clj-kondo 2025-02-21

Just published a small config "lib" using the recent extensions to discouraged-var and min-clj-kondo-version: https://github.com/imrekoszo/unlazy

๐ŸŽ‰ 7

As for mapv's high arities would (into [] (map ...) ...) work?

Sadly, no. The only transducing context I know of that can use a multi-coll map is sequence, which produces a lazy seq. I meant to post an ask.clojure about this for a long time now

But if you know about one then let me know!

Prs are also welcome.

nice repo! Some extra lazy functions: sequence, eduction, seque Other functions like zipmap are "as lazy as mapv" Functions like tree-seq are also lazy, but it does not have a eager alternative

looked further into zipmap and it uses seq which can be lazy

zipmap's algorithm isn't lazy, but it can accept lazy sequences

gonna need to write that ask.clojure sometime ๐Ÿ™‚

user=> (zipmap [:a :b :c] (range))
{:a 0, :b 1, :c 2}

range is lazy, a vector literal isn't, the return value of zipmap isn't a lazy sequence

yeah, that's clear

So I think it turns something like this (zipmap [:a :b :c] (eduction (map inc) [1 2 3 4])) lazy internally

you're looking to avoid internal usage of lazy sequences even when the the output is strict?

In an ideal scenario I'd want to avoid that yes

that's a much taller ask than "avoid lazyseq-producing functions" lol

> I think transducers are a fundamental primitive that decouples critical logic from list/sequence processing and construction, and if I had Clojure to do all over I would put them at the bottom. > R.H.

this is really cool

Thanks! What's even cooler is that it can be done with just a config file and a deps.edn!

right, it's honestly remarkable

Thanks for the tips! Some thoughts: sequence is my approved gate from transducerland to lazyland, when thereโ€™s a need. eduction isnโ€™t lazy in the lazy seq overhead sense, I like it when I need to produce an intermediate iterable which will be consumed (once) entirely in a subsequent step. I have never used seque but it appears a rather specialized utility function to alter the observable behavior of an already lazy sequence, which I find justifiable. zipmap doesn't appear to be lazy to me per https://github.com/clojure/clojure/blob/clojure-1.12.0/src/clj/clojure/core.clj#L6660, am I missing something? tree-seq is a good one. There's a https://github.com/cgrand/xforms/issues/20 for a transducing version of it, it seems. Might be a good idea to revive it.