My guess is that this sort of thing is too rare to justify special code. name =: (some noun) name =: (new shape) ($,) name
On Wed, Mar 5, 2014 at 5:43 AM, Dan Bron <[email protected]> wrote: > Roger wrote: > > x($,)y does make a copy of the values of y > > True, though I'd say this is implied in every statement about performance > in J, or special code that speeds it up (with a few specific, documented, > and well-known exceptions). > > Hmm, maybe it's worth making a new exception? > > name =: (some noun) > name =: (new shape) ($,) name > > -Dan > > > ----- Original Message --------------- > > Subject: Re: [Jprogramming] Remove 1s from shapes > From: Roger Hui <[email protected]> > Date: Tue, 4 Mar 2014 15:45:37 -0800 > To: Programming forum <[email protected]> > > x($,)y does make a copy of the values of y, as the following session > illustrates: > > 7!:0 '' > 2107136 > x=: 3 1 4 1 5 9 265358 $ 0.2 > 7!:0 '' > 2149590784 > t=: x > 7!:0 '' > 2149590912 > > NB. i.e. did not make a copy to make t > > x1=: (($-.1:) ($,) ]) x > 7!:0 '' > 4297074688 > > NB. i.e. made a copy to make x1 > > Or this: > > timer=: 6!:2 > timer 'x1=: (($-.1:) ($,) ]) x' > 0.574603 > > If it did not make a copy it wouldn't have taken so much time to make x1. > > > > > On Tue, Mar 4, 2014 at 3:10 PM, Dan Bron <[email protected]> wrote: > > > What Roger so humbly neglected to brag about is the hook ($,) is > supported > > by special code. > > > > In effect, the verb he provided will be instantaneous: ($,) simply > updates > > the tiny piece of memory holding the array's shape with the new shape. > > > > The value part of the array won't be touched, or even looked at. > > > > -Dan > > > > > > > > > On Mar 4, 2014, at 4:59 PM, Brian Schott <[email protected]> > wrote: > > > > > > That's funny. I almost said what you did. Thanks. > > > > > > > > >> On Tue, Mar 4, 2014 at 4:44 PM, Roger Hui <[email protected]> > > wrote: > > >> > > >> f=: ($ -. 1:) ($,) ] > > >> $ f 3 1 4 1 5 9 $ 'abc' > > >> 3 4 5 9 > > >> > > >> > > >> > > >> On Tue, Mar 4, 2014 at 1:38 PM, Brian Schott <[email protected]> > > >> wrote: > > >> > > >>> Is there a general verb that can reshape any noun with 1s in its > shape > > so > > >>> that the axes with 1s disappear? I know that most often changing > > >>> calculations slightly can eliminate the 1s before they arise, but not > > >>> always. > > >>> > > >>> For example if $a == 4 1 4 3, is there a verb that will > > >>> make generalize the result like how ,"_2]1|: does in this case? > > >>> $,"_2]1|:a == 4 4 3 > > >>> > > >>> -- > > >>> (B=) > > >>> > ---------------------------------------------------------------------- > > >>> For information about J forums see > http://www.jsoftware.com/forums.htm > > >> ---------------------------------------------------------------------- > > >> For information about J forums see > http://www.jsoftware.com/forums.htm > > > > > > > > > > > > -- > > > (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 > > > ---------------------------------------------------------------------- > 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
