>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Voc  !:  Help  Dictionary

Appendix B. Special Code

Many primitives contain special code for certain arguments to effect time and/or space savings not available to general arguments. Moreover, some phrases are “recognized” and are supported by special code. For example, the dyad of the hook (\$,) is exactly the reshape of APL (denoted by ρ); its implementation avoids actually ravelling the right argument, and in so doing saves both time and space:

```   ts=: 6!:2 , 7!:2@]
x=: 11 13 17 19 23
y=: 29 7 23 11 19\$'sesquipedalian'

(x (\$,) y) -: x \$, y
1

ts 'x (\$,) y'
0.00773981 2.09818e6
ts 'x \$, y'
0.0170125 3.14662e6
```
Instances of such special code are listed below:

= dyad word-parallel operation on Boolean arguments for the following verbs:
= < <. <: > >. >: +. +: * *. *: ^ ~: | !
<.@f both also >.@f ; avoids non-integer intermediate results on extended precision integers
<.@% dyad also <.@:% >.@% >.@:% ; special code on integer arguments; see the J6.02 release notes
i.<./ monad also i.>./ and i:<./ and i:>./ ; special code for integer and floating point lists; see the J 5.04 release notes
+ dyad also * and - ; on Windows, assembly code for integer arguments for the vector-vector, vector-scalar, and scalar-vector cases
^ dyad x^y works by repeated multiplication if x is real and y is integral
m&|@^ dyad avoids exponentiation for integer arguments
m&|@(n&^) monad avoids exponentiation for integer arguments
{&x^:a: monad special code for integer list x ; see the J 5.04 release notes
{~^:a: dyad special code; see the J 5.04 release notes
f@]^:g dyad applies f instead of x&(f@]) on each iteration; see the J 6.01 release notes
| dyad special code when the left argument is a positive power of 2; see the J 6.02 release notes
+/ .* dyad also +./ .* and ~:/ .*. ; special code in general; special code for Boolean left or right arguments and for vector right arguments; see the J 5.04 and J 6.01 release notes
-/ .* monad special code in general; special code for square matrices; special code for arrays of 2-by-2 matrices; see the J 4.05 release notes
\$, dyad also (\$,)"r ; also {, {., }., e., ; avoids ravel; see the J 4.06 release notes
x=.x,y - also =: ; in place; see the J 5.03 release notes
;@:(<@u;.n) dyad special code; see the J 5.03 release notes
;@:{ dyad special code; see the J 5.03 release notes
[;.0 both also ] ; special code for vector or matrix right arguments; see the J 5.01 release notes
f;.1 both also f;._1 f;.2 f;._2 ; avoids building argument cells for several verbs: < \$ , # [ ] {. {: <@}. <@}: ; also <&}. <@:}. etc.; see the J 4.05 release notes
f;.1 both also f;._1 f;.2 f;._2 ; special code for sparse Boolean left argument; see the J 4.06 release notes
f;.1 both also f;._1 f;.2 f;._2 ; special code when the result of f on each cut is boxed and atomic; see the J 5.03 release notes
f/;.1 both also f;._1 f;.2 f;._2 ; special code for atomic verbs = < + +. * etc.; see the J 5.03 release notes
f;.3 both also f;._3 ; special code for matrix right arguments
;@:(<@u;.n) dyad special code; see the J 5.03 release notes
# dyad special code for Boolean left arguments
#: dyad special code for (0,d)#:y where d is a positive power of 2 and y is integer; see the J 6.02 release notes
#: i.@(*/) monad also (#: i.&(*/)) , etc.; special code for non-negative integer vectors; see the J 4.05 release notes
x&(128!:3) monad special code to pre-compute look-up table of CRC values for each byte
=/"r monad also < <: > >: +. +: * *. *: ~: ; word-parallel operations on Boolean arguments; also special code for insert over an axis of length 2; see the J 5.03 release notes
+/ monad also * and - ; on Windows, assembly code for integer arguments
,/ monad also ,. ; ,&.> ,.&.> ; linear time; see the J 4.05 and J 7.01 release notes
m b./ both special code for bitwise Boolean functions; see the J 5.01 release notes
f/@, monad also f/@:, f/&, f/&:, ; avoids ravel; see the J 4.05 release notes
f/@:g dyad also [: f/ g ; special code for atomic f and g ; further optimizations for +/@:g ; see the J 6.01 release notes
#/. dyad avoids building argument cells; see the J 5.03 release notes
+//. monad also +. *. = ~: <. <: >. >: 17 b. 22 b. 23 b. ; avoids building argument cells; see the J 6.01 release notes
+//. dyad also +. *. <. >. = ~:  n b. for various vector right arguments; avoids building argument cells; see the J 5.03 and J 6.02 release notes
</. i.@# monad also x</.i.#x ; special code; see the J 5.03 release notes
({.,#)/. dyad also (#,{.)/. ; special code; see the J 5.04 release notes
(+/%#)/. dyad avoids building argument cells; see the J 6.02 release notes
+//.@(*/) dyad also ~://.@(*./) ~://.@(+./) +//.@(*./) +//.@(+./) (22 b.)//.@(17 b./) ; avoids building argument cells; see the J 6.01 release notes
/: both also \: ; special code for several data types; special code for arguments with 5 items or less; see the J 4.05 release notes
/: dyad special code when the left and right arguments are the same boolean, literal, integer, or floating point vector; also for /:"1 when the left and right arguments are the same boolean, literal, integer, or floating point arrays; also for \: ; see the J 5.01 release notes
/:~ monad special code for boolean, literal, integer, or floating point vectors; also for /:~"1 and /:"1~ ; also for \: ; see the J 5.01 release notes
/:@/: monad also /:@:/: and /:&/: etc.; special code; see the J 5.04 release notes
{/: dyad also {/:~ ; special code for scalar integer left argument and integer or floating point vector right argument; see the J 6.03 release notes
#\ monad special code; see the J 7.01 release notes
=/\ monad also +. *. ~: ; word-parallel operations on Boolean arguments
+/\ monad also * and - ; on Windows, assembly code for integer arguments
+/\ dyad also <. >. +. *. = ~:  m b. for atomic m e. 17 22 23 25 ; special code for positive left arguments and boolean, integer, or floating point right arguments; see the J 5.03 and J 6.02 release notes
[\ dyad also ] and , ; see the J 5.01 release notes
2 f/\y dyad special code; see the J 4.06 and J 6.01 release notes
m b./\ monad special code for bitwise Boolean functions; see the J 5.01 release notes
(+/%#)\ dyad special code for positive left arguments and integer and floating point right arguments; see the J 5.03 release notes
#\. monad special code; see the J 7.01 release notes
=/\. monad also < <: > >: +. +: *. *: ~: ; word-parallel operations on Boolean arguments
+/\. monad also * and - ; on Windows, assembly code for integer arguments
m b./\. monad special code for bitwise Boolean functions; see the J 5.01 release notes
f/\. dyad special code for atomic associative f ; see the J 6.02 release notes
{ dyad special code for right arguments of several data types; special code for integer left arguments; special code for indexing first two axes
<"1@[ { ] dyad avoids <"1 if left argument is integer array
p{~q i.] monad also (q i.]) { p"_  and  q&i.{p"_ ; special code when p and q are literal lists; see the J 6.02 release notes
{/: dyad also {/:~ ; special code for scalar integer left argument and integer or floating point vector right argument; see the J 6.03 release notes
a=: c}x,y,:z - avoids catenation and lamination; in-place if c is Boolean and a is x or y ; see the J 4.05 release notes
y=: x i}y - in-place
y=: y i}~ x - in-place; see the J 6.03 release notes
f"r both numerous verbs have integrated rank support
 monad and dyad <. <: < >. >: + +. +: * *. *: - -: % ^ ~: | |. |: , ,: ! /: \: [ ] {. }. o. monad only -. %: ^. #. ,. / \ \. {: }: @. ? A. H. j. p. p: q: r. t. x:  /:@/:  +/%# dyad only = > \$ # { e. i. i:  \$,  m b.  -.@-:
For (+/%#)"r see the J 6.02 release notes.
^@o. monad special code; see the J 7.01 release notes
"."0@": monad also @: or & or &: instead of @ ; special code; see the J 6.01 release notes
f0`...`fn@.v"0 monad special code if f0 , ... , fn are atomic; see the J 5.02 release notes
x&(128!:3) monad special code to pre-compute look-up table of CRC values for each byte
m&i. monad also m&i: -.&m  e.&m ; see the J 5.04 release notes
u&.(a.&i.) monad special code if u-:u"0 ; see the J 6.02 release notes
m b./&.(a.&i.) monad avoids conversion to and from integers; see the J 6.02 release notes
m b.&.(a.&i.) dyad avoids conversion to and from integers; see the J 6.02 release notes
? monad also ?. ; special code if argument is identically 2
?@\$ dyad also ?. ; also ?@# ; also [: ? \$ ; special code; see the J 5.03 release notes
e.i.0: dyad see the f i.0: entry below
E. monad special code for Boolean and literal vector arguments
E.i.1: dyad see the f i.0: entry below
i. monad also i: ; special case for length-1 arguments
i. dyad also e. and i: ; special code for several data types; special code for i.!.0 ; special code for the monad i.~ or x i. x ; special code for arguments with many identical columns; see the J 4.05 release notes
f i.0: dyad special code for the following functions; see the J 5.01, J 5.03, and J 5.04 release notes.
 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.
i.<./ monad also i.>./ and i:<./ and i:>./ ; special code for integer and floating point lists; see the J 5.04 release notes
m&i. monad also m&i: -.&m  e.&m ; see the J 5.04 release notes
p {~ q i. ] monad also (q i. ]) { p"_ and q&i. { p"_ ; special code when p and q are literal lists; see the J 6.02 release notes
I.@:< dyad see the f i.0: entry above
+/%# monad special code for the following:
 (+/%#)/. J 6.02 (+/%#)\ J 5.03 (+/%#)"r J 6.02

>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Voc  !:  Help  Dictionary