This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-30
Channels
- # babashka (19)
- # beginners (87)
- # calva (11)
- # cider (6)
- # cljdoc (30)
- # clojure (84)
- # clojure-china (1)
- # clojure-dev (13)
- # clojure-europe (4)
- # clojure-france (1)
- # clojure-gamedev (1)
- # clojurescript (12)
- # core-async (1)
- # cursive (12)
- # data-oriented-programming (1)
- # defnpodcast (1)
- # emacs (9)
- # events (1)
- # fulcro (8)
- # graalvm (1)
- # introduce-yourself (1)
- # missionary (6)
- # music (1)
- # nextjournal (14)
- # off-topic (26)
- # portal (2)
- # re-frame (1)
- # releases (2)
- # shadow-cljs (13)
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)
Is it just one radix you use a lot, or several?
If you need that, use interop
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
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
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.
if the why refers to my initial question, it’s to preserve order while being able to look up values by association
The lookup time is O(n) for array-maps, not sure if that is an issue for you.
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