Hi Jon, thanks for your reply.
inspired by your use of flip,
here's what I came up with:

:: enlarge-seq ( seq item to  -- seq' )
     to seq length - :> gap
     seq gap 0 > [ gap item <array> append ] when ;

: distribute-groups ( seq^2 -- seq )
     dup [ length ] [ max ] map-reduce
     '[ f _ enlarge-seq ] map
     flip concat sift ;

basically same as your 'flip concat', but when a vector is longer than 
others, it enlarges the other ones, so data won't be lost.
and it positions them so that the next item would be from a different 
group, as far as possible.

I'm still interested in seeing a lower level solution, if I didn't have 
flip.

Many thanks, Kobi

On 12/08/2010 01:26, Jon Harper wrote:
> I don't know if this will help you understand, but here's how you can
> solve your problem. It's all about knowing the words at your disposal
> from the library..
>
> ( scratchpad ) {
>      V{ { 1 "e" } { 1 "f" } { 1 "g" } }
>      V{ { 2 "a" } { 2 "b" } { 2 "c" } }
> } flip concat .
> { { 1 "e" } { 2 "a" } { 1 "f" } { 2 "b" } { 1 "g" } { 2 "c" } }
> Cheers,
> Jon
>
>
>
> On Wed, Aug 11, 2010 at 10:00 PM, Kobi Lurie<k_lu...@gbrener.org.il>  wrote:
>>   Hi all,
>> Thanks for bearing with my questions.
>>
>>   I'm trying to understand how to do more complex sequence operations in
>> factor.
>> (and don't really know how to solve this, with my current knowledge of
>> tools)
>> say I have pairs of objects,
>>
>> {
>>      V{ { 1 "e" } { 1 "f" } { 1 "g" } }
>>      V{ { 2 "a" } { 2 "b" } { 2 "c" } }
>> }
>>
>> (the inner vectors length may differ from each other, and also there can
>> be more than 2 vectors inside)
>>
>>
>> I want to have them interleaved, according to the first item in the pair:
>>
>> { { 1 "e" } { 2 "a" } { 1 "f" } { 2 "b" } { 1 "g" } { 2 "c" } }
>> (to spread them equally)
>>
>> my thought was to use map, but how can I map vertically?
>> that is, take the first item from all sequences, then take the second..
>>
>> How would you implement this, and which language construct to use here?
>>
>> Thanks in advance, Kobi
>>
>> --
>> China: stop persecuting Falun Gong!
>> http://faluninfo.net
>>
>> URGENT: Innocent people are being persecuted for their belief inside 
>> Communist China.
>>
>>
>> ------------------------------------------------------------------------------
>> This SF.net email is sponsored by
>>
>> Make an app they can't live without
>> Enter the BlackBerry Developer Challenge
>> http://p.sf.net/sfu/RIM-dev2dev
>> _______________________________________________
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by
>
> Make an app they can't live without
> Enter the BlackBerry Developer Challenge
> http://p.sf.net/sfu/RIM-dev2dev
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>


-- 
China: stop persecuting Falun Gong!
http://faluninfo.net

URGENT: Innocent people are being persecuted for their belief inside Communist 
China.


------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to