Skip to content

Instantly share code, notes, and snippets.

@sritchie
Created December 7, 2011 22:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sritchie/1444898 to your computer and use it in GitHub Desktop.
Save sritchie/1444898 to your computer and use it in GitHub Desktop.
(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