You're viewing version 1.2.0 of project. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

project

clojure.set

  • (project xrel ks)
Returns a rel of the elements of xrel with only the keys in ks

1 Example top

  • ;; `project` strips out unwanted key/value pairs from a set of maps. 
    ;; Suppose you have these descriptions of cows:
    
    user=> (def cows #{  {:name "betsy" :id 33} {:name "panda" :id 34} })
    #'user/cows
    
    ;; You care only about the names. So you can get them like this:
    
    user=> (project cows [:name])
    #{{:name "panda"} {:name "betsy"}}
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/set.clj:71 top

(defn project
  "Returns a rel of the elements of xrel with only the keys in ks"
  {:added "1.0"}
  [xrel ks]
    (set (map #(select-keys % ks) xrel)))
Vars in clojure.set/project: defn map select-keys set
Used in 0 other vars

Comments top

No comments for project. Log in to add a comment.