one simple strategy is to make just one append: timespacex ' ;/ i.5e4' 0.004161 7.86035e6 timespacex ' (;/ i.5e4) , ;/ (i.5e4)' 0.00985 1.67685e7
build up what you want to append then do it just once. ----- Original Message ----- From: Joe Bogner <[email protected]> To: [email protected] Cc: Sent: Monday, March 10, 2014 7:33:28 AM Subject: Re: [Jprogramming] strategies for building long lists of boxes Is this an example of what you're referring to? bld2=: 3 : 0 (<'.') 4 : 'y , x' ^:y '' ) ts 'l=:bld2 1e2' 0.00177792 6400 ts 'l=:bld2 1e3' 0.0850437 20544 ts 'l=:bld2 1e4' 8.28457 217152 $ l 10000 Looping explicitly is similar bld4 =: 3 : 0 l=:'' for. i. y do. l=:l,(<'.') end. ) ts 'l=:bld4 1e4' 5.41629 199104 If so, I agree there needs to be a more efficient way On Mon, Mar 10, 2014 at 7:05 AM, Linda Alvord <[email protected]> wrote: > > Raul, Since I have a math background, I'm rather fond of x and y and am > not in any hurry to eliminate them. > However, I like boxes and will ponder your ideas - at least conceptually. > > Thanks for all your coaching! > > Linda > > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of bill lam > Sent: Monday, March 10, 2014 3:30 AM > To: Programming forum > Subject: Re: [Jprogramming] strategies for building long lists of boxes > > we can build internal representation (3!:1 or 3) of the box array and > convert it using 3!:2, not sure if this can improve time or space > efficiency. > > On Mon, Mar 10, 2014 at 2:37 PM, Raul Miller <[email protected]> wrote: >> Since using , to build boxed arrays does not currently have any code to >> support it, time is O(n^2). In other words: inefficient for long lists of >> boxes. >> >> So let's say we wanted to build lists of 30000 boxes, how could we do that >> efficiently? >> >> It seems to me that the right thing to do would be: pick a threshold > (maybe >> 1000 boxes) and when your list gets that long, append that intermediate >> result to a result list and start a fresh instance of the working list. >> Repeat until done (and don't forget to append the last intermediate list > to >> the result). >> >> Conceptually speaking, this is still O(n^2). But it should also be orders >> of magnitude faster (at the cost of some complexity) than use of unadorned >> comma. (And conceptually speaking one might be able to define some kind of >> "infinite" representation of this algorithm which has better than O(n^2) >> performance. Maybe O(n log n)? >> >> Thanks, >> >> -- >> Raul >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
