Fork me on GitHub

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!

👀 3
eccentric J16:11:10

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?

eccentric J16:11:08

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.

eccentric J17:11:03

(->> [{:color :blue
       :size :l}
      {:color :red
       :size :s}
      {:color :green
       :size :s}
      {:color :purple
       :size :s}]
     (filter #(where? % {:size :s})))

Emlyn Corrin16:11:53

Not a core function, but sounds a lot like


#(= :s (:size %))


I also have some submap? function in some tests but that's not in core


#(= (select-keys %2 (keys %1)) %1)

eccentric J17:11:00

That’s what I went with noisesmith, I must have been thinking about the submap? predicate that I think Alex posted somewhere once.


In the spec tests