My theory suggested in name of post is that functions that do in place 
assignment lose those benefits if the abstraction is used, and at least negate 
the benefit by overwriting the value with "the same" (previously in place 
modified) value.


In the assignwith definition,

replacing ((y) =: ...) with (y assign ...) has a performance hit.

But both use much more memory (and so time) than (NAME =: u NAME)



a =. i. 10000 4  NB. fairly small

timespacex 'a =: a , 1 2 3'
3.2e_6 1792


timespacex '1 2 3 (] assign  (,~ ".)) ''a'''
3.5248e_5 528256


equivalent assignwith slightly faster, but same memory


----- Original Message -----
From: Raul Miller <[email protected]>
To: Beta forum <[email protected]>
Sent: Tuesday, July 19, 2016 11:43 AM
Subject: Re: [Jbeta] with effort for inplace assignment performance

What's wrong with just using this:

   assign =: 4 : '(x) =: y'

Or, perhaps better

  Assign =: 1 : '(m) =: y'

?

These are concise definitions, they get the job done, and they do not
require any engine changes. (Which, at least in principle, allows work
to instead be done on something else.)

Put differently, what problems does this proposal solve?

Thanks,

-- 
Raul


On Wed, Jul 13, 2016 at 6:51 PM, 'Pascal Jasmin' via Beta
<[email protected]> wrote:
> I'd suggest a new built-in conjunction.  Say 128!:6 or A:
>
> assignwith =: 1 : 0
> (y) =: u (y~ [ ]) :: ((i.0)"1) 1
> :
> (y) =: x u (y~ [ ]) :: ((i.0)"1) 1
> )
>
> assignwithC =: 2 : 0
> (y) =: u (y~ [ ]) :: (n"_) 1
> :
> (y) =: x u (y~ [ ]) :: (n"_) 1
> )
>
> the error checking (::) is there to set an initial value if the name doesn't 
> exist.
>
>  1 , assignwith (][ +: assignwith) 2 (][ , assignwith) (][erase) 'aa'
> 1 4
>
> The adverb version can be shortened to
>
> 1 : 0
>
> (y) =: u ". y
> :
> (y) =: x u ". y
> )
>
>
> which is a neat feature of ".
>
> An alternative to allow tacit definitions of assignments would be the 
> ordinary dyad:
>
> =::
>
> assign =: 4 : '(x) =: y'
>
> the pattern ([ =:: u) or (] =:: u) would seem straightforward to "boost" with 
> special code for in place assignment.
>
> assignwith =: (] assign (u@:".)) : (]assign (u ".))
>
>
> I imagine this as easy and very useful, especially in combination with 
> inplace improvements.
> ----------------------------------------------------------------------
> 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

Reply via email to