Here's my first attempt:

(defn all-vals [key coll]
  (let [all-vals-w-key (partial all-vals key)]
    (cond
      (map? coll)
      (concat [(key coll)] (all-vals-w-key (vals coll)))

      (or (vector? coll) (seq? coll))
      (apply concat (map all-vals-w-key coll)))))

Call it like so:

(fact
  (all-vals :distance {:goat "al" :distance 35})
  => [35])

(fact
  (all-vals :distance [{:goat "al" :distance 35}
           {:goat "paula" :distance 25}])
  => [35, 25])

(fact
  (all-vals :distance [{:goat "al" :distance 35}
           {:goat "paula" :distance 25 :other {:distance 99}}])
  => [35, 25, 99])

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to