Ok. Thanks. What explains the huge time difference? Does the compiler somehow “know” it’s only dealing with one element in the in place assignment?
> On 25 Oct 2020, at 7:25 pm, Lippu Esa <[email protected]> wrote: > > Hello > > It is not expensive if an in place assignment can be made: > > a=.i.1e7 > ts '(_999+1000{a) 1000 }a' > 0.07655064 134219392 > ts 'a=.(_999+1000{a) 1000 }a' > 0.00000177 1792 > > Esa > > -----Original Message----- > From: Programming <[email protected]> On Behalf Of > pietdion > Sent: Sunday, October 25, 2020 9:58 AM > To: Programming forum <[email protected]> > Subject: [Jprogramming] Adding constant to a specified element of a vector > > What is the best way to add, say, scalar x to component i of vector y? > > One way is (x + i{y) i} y > But this seems clumsy/expensive. > Is there a cleaner/more efficient way? > ---------------------------------------------------------------------- > For information about J forums see > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&data=04%7C01%7C%7C846dab3174224b01be8508d878bbba64%7C5090e269dbea4e98a9aa3e70be5890f7%7C0%7C0%7C637392094979944278%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=q2LAzVmaMgPTY86v0%2FpBEascSJSwOoSYOMbgwC%2FxQUQ%3D&reserved=0 > > Tämän viestin sisältö liitteineen on luottamuksellinen ja tarkoitettu vain > sen vastaanottajalle. Jos et ole viestin tarkoitettu vastaanottaja, pyydämme > sinua poistamaan viestin liitteineen ja sen jälkeen ilmoittamaan asiasta > välittömästi viestin lähettäjälle. Viestin sisällön paljastaminen, > kopioiminen tai muu käyttö on kielletty. > > The contents of this message and any attachments are confidential and meant > solely for the intended recipient. If you are not the intended recipient, we > kindly ask that you delete the message and its attachments, and immediately > notify the sender of the email. Disclosing, copying or using the contents of > the message is strictly prohibited. > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
