(mapcat (fn [[k coll]] (map vector (repeat k) coll))
        [[:a [1 2]] [:b [3 4]]])
 
=> '([:a 1] [:a 2] [:b 3] [:b 4])


On Sunday, June 8, 2014 2:12:19 PM UTC-5, boz wrote:
>
> Is there a better way to take this...
>
> [[:a [1 2]] 
>  [:b [3 4]]]
>
> and convert it to this...
>
> [[:a 1] 
>  [:a 2] 
>  [:b 3] 
>  [:b 4]]
>
> than using a loop like this...
>
> (defn doit [id v]
>   (loop [a (first v) r (rest v) result []]
>     (if a
>       (recur (first r) (rest r) (conj result [id a]))
>       result)))
>
> ???
>
> Thanks!
> ,boz
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to