Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(def src [[{:name "smeagol"}]
[{:name "gollum"}]
[{:tuple "field!"}]])
;; Retrieve some field from a bunch of records:
(??<- [?name]
(src ?m)
(get ?m :name :> ?name))
;;=> (["smeagol"] ["gollum"])
;; Using !name keeps the nils around:
(??<- [!name]
(src ?m)
(get ?m :name :> !name))
;;=> (["smeagol"] ["gollum"] [nil])
;; Filter based on a map field:
(??<- [?m]
(src ?m)
(get ?m :name :> "smeagol"))
;;=> ([{:name "smeagol"}])
;; or on the presence of a key:
(??<- [?m]
(src ?m)
(contains? ?m :name)
(:distinct false))
;;=> ([{:name "smeagol"}]
;; [{:name "gollum"}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment