Hmmm...

We're working with rank 1 lists here, so 40 bytes overhead for each array.

Also, I think we should assume a 64 bit J implementation, so another 8
bytes for each value in these arrays.

So... 'a' would be 800040 bytes and 'b' would be 80 bytes.

Anyways... the expression b { 9999999 ,~ ] a looks like it'll build a
modified copy of a for another 800048 bytes and then build its result
for another 80 bytes. Hypothetically speaking, that 800048 byte
intermediate result could be avoided, and I guess this is a relatively
common pattern for people wanting to avoid index errors.

That said, testing, on j901, I see timespacex reporting 1536 bytes
consumed in the intermediate result. So I guess that means you've
implemented support for this pattern. Sounds good to me.

On the other hand, the operations in this example are much simpler
than typical cases for u in u^:n, aren't they?

Thanks,

-- 
Raul


On Wed, Mar 4, 2020 at 2:04 PM Henry Rich <[email protected]> wrote:
>
> It's hard to know what the interpreter might get away with.  How many
> bytes will be used by the last sentence in this sequence?
>
>     a =. 1e5 ?@$ 1e5
>     ]b =. a i. 4 5 6 7 8
> 100000 4592 7680 5095 18231
>     b { 9999999 ,~ ] a
> 9999999 5 6 7 8
>
>
> Henry Rich
>
>
>
>
> On 3/4/2020 1:19 PM, Raul Miller wrote:
> > Unless you're working with memory mapped files -- which are a
> > reflection of an external (os) mechanism -- named nouns in J are copy
> > on write.
> >
> > For example:
> >     a=:p:i.4
> >     b=:a
> >     a=:a 1}~ 9
> >     a
> > 2 9 5 7
> >     b
> > 2 3 5 7
> >
> > Thanks,
> >
>
>
> --
> This email has been checked for viruses by AVG.
> https://www.avg.com
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to