The solution
(flatten (interleave (partition 1 2 xy)  (partition 1 2 (rest xy)) z))
works provided that none of the elements of xy or z are seqs.

For example if xy = [[1 3] [2 4] [3 7] [4 7]] and z= [[5] [6]] this
solution produces
(1 3 2 4 5 3 7 4 7 6).

The other proposal (interleave (take-nth 2 xy) (take-nth 2 (rest xy))
z) produces
([1 3] [2 4] [5] [3 7] [4 7] [6]).

Alan

On 27 June 2013 12:41, Paul Meehan <paulchristophermee...@gmail.com> wrote:
> given sequences xy and z
>
> (flatten (interleave (partition 1 2 xy)  (partition 1 2 (rest xy)) z))
>
> works..
>
>
> On Thursday, June 27, 2013 11:37:40 AM UTC+1, Paul Meehan wrote:
>>
>> Hi,
>>
>> Given a sequence (x1, y1, x2, y2, x3, y3,...)
>>
>> and another (z1, z2, z3, ...)
>>
>> I want to interleave such that I get a sequence
>>
>> (x1, y1, z1, x2, y2, z2, x3, y3, z3, ...)
>>
>> What's the most succinct way to achieve this?
>>
>> thanks
>> Paul
>
> --
> --
> 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
> ---
> 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 clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
-- 
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
--- 
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to