This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-18
Channels
- # atom-editor (5)
- # babashka (15)
- # beginners (80)
- # calva (11)
- # cestmeetup (6)
- # chlorine-clover (15)
- # cider (22)
- # circleci (3)
- # clojure (57)
- # clojure-europe (19)
- # clojure-italy (1)
- # clojure-nl (4)
- # clojure-spec (1)
- # clojure-switzerland (1)
- # clojure-uk (88)
- # clojurescript (92)
- # code-reviews (1)
- # cursive (6)
- # data-science (5)
- # datascript (6)
- # datomic (12)
- # events (7)
- # figwheel-main (2)
- # fulcro (55)
- # graalvm (2)
- # helix (6)
- # juxt (6)
- # kaocha (11)
- # luminus (2)
- # off-topic (82)
- # pathom (27)
- # portal (1)
- # re-frame (3)
- # reitit (25)
- # remote-jobs (8)
- # sci (11)
- # shadow-cljs (29)
- # slack-help (2)
- # spacemacs (9)
- # specter (4)
- # sql (9)
- # tree-sitter (1)
- # uncomplicate (1)
- # xtdb (26)
not-empty?
should be a thing. 🙊
Good morning.
idioms are only idioms to the extent that they are commonly used and understood, I guess either you lean into it and use it freely so people also have more chance of coming across and absorbing the idiom, or you go the other way. It also really depends on your audience. If I use (some #{foo} coll)
in a lambda island episode then I feel like I need to explain that, so I may use (contains? (set coll) foo)
which I think is a bit more readily understood. But in my own code I would probably write (some #{foo} coll)
agree completely on use and leaning into the use being the important thing about idioms
that contains? bit confuses me, but then I don't use contains? much as it feels like a false friend when I think about using it
I suppose it is useful for being able to do things like this:
user> (contains? {:a nil} :a)
true
user> (contains? {} :a)
false
I use contains?
etc on hot paths since it's more performant:
user=> (time (let [m {:a 1} k :a] (dotimes [i 100000000] (some m [:a :b]))))
"Elapsed time: 2553.732969 msecs"
nil
user=> (time (let [m {:a 1} k :a] (dotimes [i 100000000] (or (contains? m :a) (contains? m :b)))))
"Elapsed time: 553.231016 msecs"
nil