[Jprogramming] choosing between alternates (iif, ifelse)
Ric Sherlock
tikkanz at gmail.com
Thu Dec 22 03:21:20 HKT 2011
On Thu, Dec 22, 2011 at 5:54 AM, Henry Rich <HenryHRich at 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
More information about the Programming
mailing list