clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
2020-11-15T03:37:30.096Z

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!

👀 1
Heiko Vogeler 2020-11-15T14:21:36.099400Z

ä

2020-11-15T16:55:10.100400Z

It’s possible I’m conflating it with another language but isn’t there a core function for filtering things with a map?

borkdude 2020-11-15T16:56:07.100800Z

@jayzawrotny Maybe the map itself is the filter?

2020-11-15T16:57:08.101300Z

It would be for filtering other maps in a collection

borkdude 2020-11-15T16:59:14.101800Z

It depends on your example. Keywords and maps implement IFn, so you can use them as a filter fn.

2020-11-15T16:59:20.102Z

Right

2020-11-15T17:01:03.102400Z

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

Emlyn Corrin 2020-11-18T16:44:53.307200Z

Not a core function, but sounds a lot like https://github.com/BrunoBonacci/where

borkdude 2020-11-15T17:05:17.102700Z

#(= :s (:size %))

borkdude 2020-11-15T17:05:59.103200Z

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

2020-11-15T17:19:30.103800Z

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

2020-11-15T17:29:00.104400Z

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

borkdude 2020-11-15T17:32:53.104600Z

In the spec tests