This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-17
Channels
- # babashka (4)
- # beginners (161)
- # calva (19)
- # cider (13)
- # circleci (16)
- # clj-kondo (7)
- # cljs-dev (3)
- # cljsrn (46)
- # clojure (105)
- # clojure-australia (2)
- # clojure-nl (15)
- # clojurescript (20)
- # conjure (14)
- # core-async (8)
- # cursive (3)
- # datomic (4)
- # figwheel (5)
- # fulcro (22)
- # graalvm (1)
- # hoplon (2)
- # kaocha (3)
- # leiningen (6)
- # malli (5)
- # off-topic (19)
- # re-frame (5)
- # reagent (1)
- # reitit (43)
- # releases (1)
- # reveal (14)
- # rewrite-clj (2)
- # rum (1)
- # shadow-cljs (31)
- # spacemacs (2)
- # sql (6)
- # xtdb (8)
clj-kondo flags this: (set/difference #{:a :b} (keys {:a 1}))
but it actually does work. That seq from keys
can be used like a set
@kevin842 this is undeterministic behavior.
(instance? java.util.Set (keys {:a 1}))
false
E.g. this will crash:
user=> (set/difference #{:a :b} (keys {:a 1 :b 2 :c 3}))
Execution error (IllegalArgumentException) at user/eval7 (REPL:1).
contains? not supported on type: clojure.lang.APersistentMap$KeySeq
oh, interesting! I wonder why that is the case.. isn't it just a view over the actual collection, which it knows to support o(1) access?
I must be thinking of python, where dict.keys() does return a set-like view:
>>> "b" in {"a": 1, "b": 2}.keys() True
in any case not relevant to this channel :)