clojure-dev

quoll 2022-01-30T01:12:14.537579Z

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)

seancorfield 2022-01-30T02:31:06.299119Z

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

quoll 2022-01-30T04:08:37.405059Z

Mostly 16. Occasionally 2

Alex Miller (Clojure team) 2022-01-30T04:09:36.890689Z

If you need that, use interop

quoll 2022-01-30T04:17:59.213919Z

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) 2022-01-30T04:40:35.749599Z

Not trying to hit every use

👍 1
borkdude 2022-01-30T08:02:22.855709Z

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

denik 2022-01-30T20:42:37.951809Z

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

2022-01-30T20:50:32.085539Z

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.

ghadi 2022-01-30T20:50:38.324829Z

why

☝️ 1
denik 2022-01-31T02:06:50.848879Z

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

2022-01-31T04:31:22.467129Z

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

👍 1
2022-01-31T04:33:03.208489Z

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