Without the special code the performance can be improved slightly (in this case):
ts 'c}b,:a' 0.01927602 41945088 ts' a+c*b-a' 0.016176513 25167616 (c}b,:a)-:a+c*b-a 1 R.E. Boss > -----Oorspronkelijk bericht----- > Van: programming-boun...@jsoftware.com [mailto:programming- > boun...@jsoftware.com] Namens Ric Sherlock > Verzonden: woensdag 21 december 2011 20:21 > Aan: Programming forum > Onderwerp: Re: [Jprogramming] choosing between alternates (iif, ifelse) > > On Thu, Dec 22, 2011 at 5:54 AM, Henry Rich <henryhr...@nc.rr.com> > wrote: > > Note that > > > > c}b,:a > > > > does indeed compute b,:a. But if it's used in the precise form > > > > result =: c}b,:a > > > > the computation is avoided. > > > > b =: 1e6$4 > > a =: 1e6$4 > > c=: ? 1e6$ 2 > > ts 'c}b,:a' > > 0.0401299 2.09725e7 > > ts 'q =: c}b,:a' > > 0.0112949 4.19558e6 > > > > There are other special cases; see the Special Code page. > > Especially the "in-place" case where items of b or a are altered in-place. > Note that timespacex is defined in the stdlib in J7. > > timespacex ' c}b,:a' > 0.0229656 4.19451e7 > timespacex 'q=: c}b,:a' > 0.00915218 8.39091e6 > timespacex 'b=: c}b,:a' > 0.00612322 2304 > timespacex 'b=: c}b,:a' > 0.00612322 2304 > timespacex 'b=: c}a,:b' > 0.00615121 2304 > timespacex 'a=: c}b,:a' > 0.00612789 2304 > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm