This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-30
Channels
- # asami (10)
- # babashka (14)
- # beginners (71)
- # calva (56)
- # cider (8)
- # cljs-dev (3)
- # clojure (111)
- # clojure-australia (1)
- # clojure-europe (19)
- # clojure-nl (4)
- # clojure-uk (147)
- # clojurescript (4)
- # cursive (8)
- # datalog (1)
- # datomic (19)
- # emacs (4)
- # graalvm (32)
- # helix (14)
- # jackdaw (7)
- # jobs-discuss (10)
- # juxt (4)
- # lsp (3)
- # malli (47)
- # meander (6)
- # off-topic (29)
- # portal (6)
- # re-frame (1)
- # react (3)
- # reitit (24)
- # releases (1)
- # remote-jobs (4)
- # reveal (33)
- # rewrite-clj (3)
- # shadow-cljs (5)
- # sql (10)
- # tools-deps (4)
- # vim (7)
- # xtdb (151)
what is the fastest way to scan a collection? there is something faster than a m/scan
?
(require '[taoensso.encore :as enc])
(require '[meander.epsilon :as m])
(def data (vec (repeatedly 1000000 (fn [] {:a (* (rand-int 100) (if (enc/chance 0.5) 1 -1))
:b (* (rand-int 100) (if (enc/chance 0.5) 1 -1))
:c (* (rand-int 100) (if (enc/chance 0.5) 1 -1))}))))
(enc/qb 1
(doall
(m/search data
(m/scan {:a 1 :b 1 :c 1 :as ?m}) ?m))
(->> data
(filterv
(fn [m]
(m/find m
{:a 1 :b 1 :c 1 :as ?m} ?m)))))
;; => [127.33 60.28] - in ms