Fork me on GitHub

Just stumbled upon Basically I have a fn that takes a coll and I wanted to be sure it was distinct regardless of type. I see this question has no Jira ticket on it. Any chance of that happening?


Sort of related, but why isn’t distinct implemented as (seq (set coll)) ?


Distinct is lazy and preserves order. That does neither

Alex Miller (Clojure team)14:02:08

btw, the transducer version will work with sets


Does that make it worse or better?


(sorry late Friday here)

Alex Miller (Clojure team)14:02:21

it provides a solution now in lieu of a change

Alex Miller (Clojure team)14:02:35

but I will file a ticket for it


I notice that there is opportunity to reduce a lot of allocations in int-maps during iteration, if we have Leaf nodes ( extend clojure.lang.MapEntry (since that is what they are basically anyways) Then its iterator can return this instead of new MapEntry(key, value) and similarly its reduce method can invoke on this rather than new MapEntry(key, value) On an int-map of 50k entries I observe about 40% speedup in reduce by doing that


a complication is that int MapEntry.count() { return 2 } clashes in both meaning and signature with long INode.count() (which should return 1). So INode.count would need to be renamed to like nodeCount() or something.


I don't have a way to check out against the latest build of Clojure(JVM), but I'm wondering about the effects of commit on LongRange chunking. Prior to this commit LongRange had similar logic to what is still in Range for chunking, namely forceChunk would make sure that the LongChunk created had size no more than CHUNK_SIZE = 32 . in the new code, the LongChunk will have size equal to the size of the LongRange. I'm guessing this will be a surprise to anyone trying (take 1 (map f (range 1000000))) who likely will expect f to be called at most 32 times. (I'm basing this on comparing my current install of clj = 1.11.1 against the latest ClojureCLR which has this change. I used a side-effecting f . For clj f is called 32 times. for ClojureCLR, well, at least in only tested it against 100 and not 1,000,000. Tracing through my code vs current JVM code, I don't think the problem is just on my side.)

Alex Miller (Clojure team)22:02:50

this is been changed back in master

Alex Miller (Clojure team)22:02:38

or maybe it hasn't been ok'ed yet


doesn't show in the repo yet. My usual assumption is that something is broken in my code. It took me a long time to think of checking the commit history on that file.

Alex Miller (Clojure team)22:02:46

actually had a missing field set so was not showing up in the right list, so thanks! ;)


Also didn't think to check JIRA 🙂 And all I was trying to do was come up with a final example for a blog post.