Or a more generic way:

(defn bar [n m coll]
  (when-let [s (seq coll)]
    (let [a (take n s) b (take m (drop n s))]
      (concat b a (bar n m (drop (+ n m) s))))))


On Apr 11, 4:23 pm, ataggart <alex.tagg...@gmail.com> wrote:
> How about:
>
> (defn foo [coll]
>   (apply concat
>     (map (fn [[a b c d]] [c d a b])
>       (partition 4 coll))))
>
> On Apr 11, 3:25 pm, Glen Rubin <rubing...@gmail.com> wrote:
>
>
>
> > I am working with a collection of sequences ...(e.g.
> > coll:
> > ((/f /b /c /4 /5 /6 /3 /6 /f /4 /3 /2 /4 /5 /7 /3 /6...) (/2 /b /c /4 /
> > 2 /
> > 6 /3 /7 /f /4 /3 /2 /4 /5 /7 /3 /6...)...)
>
> > I want to rearange the sequence into groups of 4 where the later 2
> > elements are moved to the front for example:
>
> > (/f /b /c /4 /5 /6 /3 /6 /f /4 /3 /2 /4 /5 /7 /3 /6...)   I want to
> > transform it as follows:
>
> > (/c /4 /f /b /3 /6 /5 /6 /3 /2 /f /4....)
>
> > I can break the collection of sequences up into groups of 4 as
> > follows:
>
> > (map #(partition 4 %) coll)
>
> > However I am having problems taking the resulting partitioned sequence
> > and further subdividing into groups of 2 before reversing the paired
> > groups order.

-- 
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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to