Thanks for the replies!!
I goofed and only gave part of my loopy solution ...
here's the whole thing
(defn do-one [id v]
(loop [a (first v) r (rest v) result []]
(if a
(recur (first r) (rest r) (conj result [id a]))
result)))
(defn do-all [x]
(loop [a (first x) b (rest x) result []]
(if a
(recur (first b) (rest b) (into result (do-one (first a) (flatten
(rest a)))))
result)))
On Sunday, June 8, 2014 12:12:19 PM UTC-7, 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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.