>>  <<  Ndx  Usr  Pri  Phr  Dic  Rel  Voc  !:  wd  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 r); 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 avoids non-integer intermediate results on extended precision integers
i.<./ monad also i.>./ and i:<./ and i:>./ ; special code for integer and floating point lists (see the J 5.04 release notes)
>.@f both avoids non-integer intermediate results on extended precision integers
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 extended precision arguments
m&|@(n&^) monad avoids exponentiation for extended precision arguments
+/ .* dyad also +./ .* and ~:/ .*. ; special code; see the J 5.04 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
;@:(<;.0) 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
;@:(<;.0) dyad special code; see the J 5.03 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
# dyad special code for Boolean left arguments
# i.@# monad also (# i.&#) , etc.; avoids i. on Boolean arguments; see the J 4.06 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 J 5.03 release notes)
+/ monad also * and - ; on Windows, assembly code for integer arguments
,/ monad also ,. ,.&.> ; ; linear time; see the J 4.05 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
#/. dyad avoids building argument cells; see the J 5.03 release notes
+//. dyad also +. *. <. >. = ~:  n b. for various vector right arguments; avoids building argument cells; see the J 5.03 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
/: 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
=/\ monad also +. *. ~: ; word-parallel operations on Boolean arguments
+/\ monad also * and - ; on Windows, assembly code for integer arguments
+/\ dyad also + <. >. +. *. = ~: ; special code for positive left arguments and boolean, integer, or floating point right arguments; see the J 5.03 release notes
[\ dyad also ] and , ; see the J 5.01 release notes
2 f/\y dyad also 2 f~/\y ; special code for atomic f and vector y ; see the J 4.06 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 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
{ 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
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
f"r both numerous verbs have integrated rank support:
= < <. <: > >. >: + +. +: * *. *: - -: % ^ ~: | |. |: $ , ,. ,: # ! [ ] { {. {: }. }: / /: \ \. \: b. e. i. i: o. p. p:
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
? 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.
   < <: > >: signal error for literal data
   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
I.@:< dyad see the f i.0: entry above



>>  <<  Ndx  Usr  Pri  Phr  Dic  Rel  Voc  !:  wd  Help  Dictionary