(Just catching up on the weekend's email now...) I am going to ignore the =. here (in `b =. ,a`), because that makes most of the rest of this make sense...
It seems to me that ,(0,.~0,.0,~0,])a is going to be as concise as you can get, unless J gets a "padding primitive". That said, if a is large, it might make sense to do some additional work up front. For example: (,a) (,((#,a)+(i.#a)*#a)+i.$a)} 0#~*/2+$a 0 0 0 0 0 0 10 11 12 0 0 13 14 15 0 0 0 0 0 0 (But I'd still want to benchmark that before I declared it "more efficient".) Thanks, -- Raul On Sat, Apr 27, 2019 at 11:02 AM Brian Schott <[email protected]> wrote: > I have a list `b =. ,a` where a is defined below. b always contains 6 > (real) atoms, not necessarily the values in the current example a. > > I want to produce b using complex x values in Copy but cannot seem to get > the correct x to do so. > > ]a =: 10+i. 2 3 > 10 11 12 > 13 14 15 > (0,.~0,.0,~0,])a > 0 0 0 0 0 > 0 10 11 12 0 > 0 13 14 15 0 > 0 0 0 0 0 > [b =. ,(0,.~0,.0,~0,])a > 0 0 0 0 0 0 10 11 12 0 0 13 14 15 0 0 0 0 0 0 > > Below are my attempts at learning to use complex x in Copy. > > 0j6 # 4 > 0 0 0 0 0 0 > 0j6 1 # 4 > 0 0 0 0 0 0 4 > > The above examples seemed to provide me a guideline, but when I try similar > examples with a list right hand argument, I seem to lose the (leading) 10 > when I don't get a length error. > > 0j6 1 1 1# 10 11 12 > |length error > | 0j6 1 1 1 #10 11 12 > 0j6 1 1 # 10 11 12 > 0 0 0 0 0 0 11 12 > 0j6 1 1 1 # 10 11 12 > |length error > | 0j6 1 1 1 #10 11 12 > > How do I get the desired result b(and preserve the 10 in the simpler > examples)? > > -- > (B=) <-----my sig > Brian Schott > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
