Fork me on GitHub
#clojure-dev
<
2022-01-30
>
quoll01:01:14

I feel like I’ve missed the boat here, but I keep finding that I have to continue to use Long/parseLong because parse-long doesn’t have the option of a radix. Was that a decision, or just not noticed? (Admittedly, I’m doing more numerical work than many people)

seancorfield02:01:06

Is it just one radix you use a lot, or several?

quoll04:01:37

Mostly 16. Occasionally 2

Alex Miller (Clojure team)04:01:36

If you need that, use interop

quoll04:01:59

I do (and I also use interop in ClojureScript). But I used interop for parsing longs in the first place, and now there's a wrapper for it. So I wondered about why one mode was wrapped but not the other. I can keep using #?, but I’m interested in every opportunity to remove conditional compilation. parse-long is part of the way there, which is why I asked

Alex Miller (Clojure team)04:01:35

Not trying to hit every use

👍 1
borkdude08:01:22

Fwiw, I've also hit this a few times.

denik20:01:37

is there a way to use into or transduce without having array-maps converted hash-maps?

(into (array-map) (map vec) (partition 2 (range 20)))
=> {0 1, 4 5, 6 7, 12 13, 2 3, 14 15, 16 17, 10 11, 18 19, 8 9}

(type (into (array-map) (map vec) (partition 2 (range 20))))
=> clojure.lang.PersistentHashMap

andy.fingerhut20:01:32

The only way I know to end up with an array-map with more than 8 keys in it is to call a constructor that always returns an array-map, and then don't do any other operations on that result.

ghadi20:01:38

why

☝️ 1
denik02:01:50

if the why refers to my initial question, it’s to preserve order while being able to look up values by association

andy.fingerhut04:01:22

The lookup time is O(n) for array-maps, not sure if that is an issue for you.

👍 1
andy.fingerhut04:01:03

There is also this Clojure data structure, which maintains insertion order but has lookup just as fast as Clojure's maps, because under the hood it is just a Clojure (unordered) map with hashing, plus a vector that remembers the key insertion order: https://github.com/clj-commons/ordered

🙏 1