Hi Group,
thought this nice puzzle would make a good occasion for a first
post. :-)
A solution to the original problem from c.l.s, with keywords replacing
symbols:
(ns sogaard-kata
(:use clojure.contrib.seq-utils))
(defn sogaard-kata [xs]
(map (fn [[k ys]] (into (vec k) (vec ys)))
(partition-all 2 (partition-by keyword? xs))))
(sogaard-kata [:a 1 2 3 :b 4 5 6 :c 7 8 9])
; -> ([:a 1 2 3] [:b 4 5 6] [:c 7 8 9])
This makes the assumption that the first item in the sequence is a
keyword; the problem seems underspecified otherwise.
All best,
Michał
--
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