Could you explain your reasoning? I understand O(n^3) time from the multiple copies - you have O(n^2) time cost multiplied by n repetitions. But space cost should be O(n^2) -- the number of copies of the array needed should have a fixed upper bound, because previous temporary copies do not need to be preserved.
I am amused though, that this illustrates a case where the interpreter is designed to be more efficient with explicit code than tacit. (Or did I miss something?) Thanks, -- Raul On Mon, Jan 13, 2014 at 3:06 PM, Henry Rich <henryhr...@nc.rr.com> wrote: > In Kip's context (repeatedly amending an array), m} is still going to create > new copies of the array, leading to memory use of O(n^3). > > An explicit version that uses assignment in place will be leaner for large > n. > > Henry Rich > > > On 1/13/2014 2:50 PM, Raul Miller wrote: >> >> This is probably too much information, and unnecessary, but maybe >> someone will find some part of it useful. >> >> http://www.jsoftware.com/help/dictionary/d530n.htm says >> >> If m is a gerund, one of its elements determines the index argument to >> the adverb } , and the others modify the arguments x and y : >> x (v0`v1`v2)} y ↔ (x v0 y) (x v1 y)} (x v2 y) >> >> In other words: >> >> 2 3 0 [` ([:{.[)` ] } i.3 3 >> 0 1 2 >> 3 4 5 >> 2 3 0 >> >> 2 3 0 [ i.3 3 >> 2 3 0 >> 2 3 0 ([:{.[) i.3 3 >> 2 >> 2 3 0 ] i.3 3 >> 0 1 2 >> 3 4 5 >> 6 7 8 >> >> 2 3 0 ( 2 ) } i.3 3 >> 0 1 2 >> 3 4 5 >> 2 3 0 >> >> (That does not quite look right in the font used by my web browser, >> but hopefully the intent is clear.) >> >> Thanks, >> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm