On Wed, Dec 2, 2009 at 2:06 PM, ataggart <alex.tagg...@gmail.com> wrote:
>
>
> On Dec 2, 9:10 am, Konrad Kułakowski (kony) <kulakow...@gmail.com>
> wrote:
>> Recently I need something which works as "inverse of interleave"
>
> How about this?
>
> (defn skip [coll n]
>  (lazy-seq
>    (when-let [s (seq coll)]
>      (cons (first s) (skip (drop n (next s)) n)))))
>
> (defn unravel [coll n]
>  (for [i (range n)]
>    (skip (drop i coll) (dec n))))

Not bad.  Your unravel takes an n, which is needed because
interleave accepts any number of collections, not just two.  Your
'skip' is a lot like take-nth.  Here's what I had:

(defn unravel [n coll]
  (map #(take-nth n (drop % coll)) (range n)))

--Chouser

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

Reply via email to