3 ms·
'Clojure has transients, which basically means "inside this function, use a mutable value under the hood while building up the value, but make it immutable befo
by ij2bun 13y ago
'Clojure has transients, which basically means "inside this function, use a mutable value under the hood while building up the value, but make it immutable before it's returned"' is this essentially a ... closure?
- augustl 13y agoTransients in Clojure is an added feature to the built in immutable values. Essentialy, they are immutable. But Clojure does have mutable-ish versions you can use to build up a semi mutable transient, and when you're done, convert it into an immutable value before it's returned. The key is to make it fast. Mutable -> immutable is not an O(N) copy.