The issue occurs when your verb causes side effects. The problem occurs by calling the unwanted function even if its return value is "correctly" discarded.
----- Original Message ----- From: 'Bo Jacoby' via Programming <[email protected]> To: "[email protected]" <[email protected]> Cc: Sent: Tuesday, July 15, 2014 4:13:22 PM Subject: Re: [Jprogramming] Why does u^:_2 execute u? This seems to work: *:^:(1 0 _1 _2)16 256 16 4 2 Den 19:18 tirsdag den 15. juli 2014 skrev 'Pascal Jasmin' via Programming <[email protected]>: > > >bug I think, but a partial workaround > >pD =: 1!:2&2 > > ''[(pD@:('norm ',":)) :. (pD@:('inverse ',":))^:_1^:2 'abc' >inverse abc >inverse inverse abc > > >doesn't help with _1 0 , or _1 _1. Also affects ^:v > > ''[0 _1 (pD@:('norm ',":@:])) :. (pD@:('inverse ',":@:]))(^:[ ) 'abc' >norm abc >inverse abc > >there is also a problem with any multiple argument: > > ''[ (pD@:('norm ',":@:])) :. (pD@:('inverse ',":@:]))^: 0 1 'abc' >norm abc >norm abc > > >can be partial fixed with removing 0s when the v argument contains multiple >items : >scalarize =: {.^:((,1) -: $) > > power =: 2 : 'u^:(0 (scalarize@:-.~^:(1<#@:]) *) v"_) ^:([: | 0 >scalarize@:-.~^:(1<#@:]) v"_)' > > ''[ (pD@:('norm ',":@:])) :. (pD@:('inverse ',":@:]))power _2 'abc' >inverse abc >inverse inverse abc > > ''[ (pD@:('norm ',":@:])) :. (pD@:('inverse ',":@:]))power 0 2 'abc' >norm abc >norm norm abc > > ''[ 0 _2 (pD@:('norm ',":@:])) :. (pD@:('inverse ',":@:]))power [ 'abc' >inverse abc >inverse inverse abc > >just _1 _1 remains a problem, but could be fixed with nub. > > >----- Original Message ----- >From: "[email protected]" <[email protected]> >To: [email protected] >Cc: >Sent: Tuesday, July 15, 2014 11:57:26 AM >Subject: [Jprogramming] Why does u^:_2 execute u? > >u^:_1 executes the inverse of u, but u&:_2, or any other value >of n containing a negative value, executes u first. I am just wondering why > > '' [ (>:@[ smoutput@('+',":)) :. (<:@[ smoutput@('-',":)) ^:(_1) 0 >-0 > > '' [ (>:@[ smoutput@('+',":)) :. (<:@[ smoutput@('-',":)) ^:(_1 0) 0 >+0 >-0 > > '' [ (>:@[ smoutput@('+',":)) :. (<:@[ smoutput@('-',":)) ^:(_2) 0 >+0 >-0 >-_1 > >The +0 lines are the surprise executions of u. The execution seems to mean >business: > > [: :. (smoutput@('inverse ',":))^:_1 'abc' >inverse abc > [: :. (smoutput@('inverse ',":))^:_1 _1 'abc' >|domain error >| [: :.(smoutput@('inverse ',":))^:_1 _1'abc' > >I just can't imagine what the business might be. > >Henry Rich > > > > > >---------------------------------------------------------------------- >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
