Recently I need something which works as "inverse of interleave"
I did something like that:
(defn unravel [expr-list]
(loop [flist () slist () tic-tac 0 olist expr-list]
(let [item (first olist)]
(if (= item nil)
(list flist slist)
(if (= tic-tac 0)
(recur (concat flist (list item)) slist
1 (rest olist))
(recur flist (concat slist (list item))
0 (rest olist)))))))
Test:
(def dl (interleave (iterate inc 1) ["A" "B" "C" "D" "E"]))
(unravel dl)
And the "classic" question is it possible to do it simple, more in a
"functional manner", without explicit looping?
--
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