[Jprogramming] Interweave

Martin Kreuzer info at airkreuzer.com
Fri Mar 11 13:28:27 UTC 2016


Thanks, that's pretty obvious now; slightly modified:

    ] v=. 5 + i.4
5 6 7 8
    ] w=. (#v) $ 1
1 1 1 1
    ] lne=. }: ,v ,.w  NB. either curtail ...
5 1 6 1 7 1 8
    ] lne=. }. ,w ,.v  NB. or behead
5 1 6 1 7 1 8

I must always remind myself that we are talking arrays (lists), so 
the loop I had in mind is probably only to be seen on the 
implementation level, not here ...

-M


At 2016-03-11 12:06, you wrote:
> > How would one go about throwing in the additional "1"s into the > 
> spaces (gaps) of the paling fence..? (There is one less "1" 
> compared > to the number of integers in the "list notation" [if I 
> always write > out the integer part, even if it is "0"). > > If the 
> two lists I like to "interweave" don't agree in number of > items, 
> I obviously get a lenght error. > >     ] v=. i.4 > 0 1 2 3 >     ] 
> w=. 3 $ 1 > 1 1 1 >     ,v ,. w > |length error > |   ,v    ,.w > > 
> Would there be a (similar, slightly modified) way to do this, or 
> does > one need a (very) different approach..? slightly modified: 
> }:,v,.w,0 Ben > -M 
> ---------------------------------------------------------------------- 
> For information about J forums see http://www.jsoftware.com/forums.htm



More information about the Programming mailing list