This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-15
Channels
- # aleph (5)
- # announcements (1)
- # architecture (35)
- # babashka (9)
- # beginners (87)
- # chlorine-clover (13)
- # cider (3)
- # cljdoc (12)
- # clojure (16)
- # clojure-australia (2)
- # clojure-dev (4)
- # clojure-europe (5)
- # clojuredesign-podcast (21)
- # clojurescript (19)
- # conjure (1)
- # core-async (1)
- # data-science (1)
- # emacs (44)
- # events (2)
- # helix (1)
- # leiningen (2)
- # malli (31)
- # pathom (3)
- # pedestal (31)
- # portal (3)
- # reagent (20)
- # reitit (5)
- # reveal (2)
- # rewrite-clj (18)
- # tools-deps (6)
- # xtdb (5)
How fun! I was looking for classes defined within Clojure's core library via deftype
, and noticed for the first time that in the pretty_writer.clj source file that is part of the clojure.pprint implementation, there is a macro called deftype
created in there that is different than clojure.core/deftype
. Fun!
It’s possible I’m conflating it with another language but isn’t there a core function for filtering things with a map?
@jayzawrotny Maybe the map itself is the filter?
It would be for filtering other maps in a collection
It depends on your example. Keywords and maps implement IFn, so you can use them as a filter fn.
Right
(->> [{:color :blue
:size :l}
{:color :red
:size :s}
{:color :green
:size :s}
{:color :purple
:size :s}]
(filter #(where? % {:size :s})))
Not a core function, but sounds a lot like https://github.com/BrunoBonacci/where
#(= (select-keys %2 (keys %1)) %1)
That’s what I went with noisesmith, I must have been thinking about the submap? predicate that I think Alex posted somewhere once.
I've been tweaking it for my tests: https://github.com/borkdude/clj-kondo/blob/ca947294b18df2b1049ceca5a29578cee89b037f/test/clj_kondo/test_utils.clj#L15