repeats # values
values (] # ($~ $)) repeats Henry Rich On 3/10/2011 8:13 AM, Charles Turner wrote: > Hi all- > > Here's a little problem (not a homework assignment) that has me stumped. > > Take two rank 1 arrays: > > repeats =: 1 2 3 4 > values =: 13 14 15 16 > > and want to repeat values such that the result is this rank 1 array: > > 13 14 14 15 15 15 16 16 16 16 > > I've gotten as far as: > >> times =: dyad : ', y"0 i. x' "0 >> 1 2 3 4 times 13 14 15 16 >> 13 0 0 0 >> 14 14 0 0 >> 15 15 15 0 >> 16 16 16 16 > > But it's the wrong rank and has been filled. And it might be really awful J > as well. > > Any pointers greatly appreciated. I've been reading mostly _J for C_, but > perhaps I should be looking at something else. > > Next step after this is to repeat arrays of unequal length: > > repeats =: 1 2 3 4 > values =: 13 14 > > result =: 13 14 14 13 13 13 14 14 14 14 > > and vice versa. > > Best wishes, > > Charles > > > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
