Help / Release / J 5.04 / e.i.1: Improved
< Help
Jump to navigation
Jump to search
>> << Pri JfC LJ Phr Dic Voc !: Rel NuVoc wd Help Release
e.i.1: Improved |
initial writing: 2004-08-18 |
The dyad e.i.1: (and others, see below) are now supported by special code. These are similar to the dyads previously described in J5.02 and J5.03. A complete table of such dyads are as follows:
f i. 0: | i.&0@:f | first place where not x f y | ||
f i. 1: | i.&1@:f | first place where x f y | ||
f i: 0: | i:&0@:f | last place where not x f y | ||
f i: 1: | i:&1@:f | last place where x f y | ||
[: + / f | + /@:f | number of places where x f y | ||
[: +./ f | +./@:f | x f y anywhere? | ||
[: *./ f | *./@:f | x f y everywhere? | ||
[: I. f | I. @:f | indices where x f y |
Notes: | |||
• | f is one of the verbs = ~: < <: > >: E. e. | ||
• | Special code is available only for Boolean, integer, floating point, literal, and symbol arguments | ||
• | Special code is used only for atoms and lists if f is not e. | ||
• | If f is E. , special code only for E.i.1: +/@:E. +./@:E. I.@:E. |
Moreover, if f is e. and the right argument is fixed, that is, (e.i.0:)&m , then that also is supported by special code. (See details here.)
The following benchmarks demonstrate the improvement:
x=: 1e6 ?.@$ 1e6 y=: 1e3 ?.@$ 1e4 a=: 'abcdefghijklmnopqrstuvwxyz' c=: a {~ 1e5 4 ?.@$ #a d=: a {~ 1e4 4 ?.@$ #a ts=: 6!:2 , 7!:2@] ts 'Expression'
Expression | J 5.04 | J 5.03 | Ratio | |||||||||
x(e.i.1:)y | 0.0000119 | 17664 | 0.0309512 | 5244160 | 2600.01 | 296.88 | ||||||
x(e.i:1:)y | 0.0000123 | 17664 | 0.0308734 | 5244160 | 2509.46 | 296.88 | ||||||
x +/@:e. y | 0.0027426 | 17792 | 0.0248151 | 2098496 | 9.05 | 117.95 | ||||||
x I.@e. y | 0.0031021 | 4211648 | 0.0265907 | 2098112 | 8.57 | 0.50 | ||||||
c(e.i.1:)d | 0.0002968 | 132352 | 0.0045880 | 656640 | 15.46 | 4.96 | ||||||
c(e.i:1:)d | 0.0002963 | 132352 | 0.0046068 | 656640 | 15.55 | 4.96 | ||||||
c +/@:e. d | 0.0032609 | 132480 | 0.0039788 | 263488 | 1.22 | 1.99 | ||||||
c I.@e. d | 0.0033605 | 656320 | 0.0041747 | 263104 | 1.24 | 0.40 |