J Reference Card For Version 6.02: Arithmetic Dyads Arithmetic Monads
J Reference Card For Version 6.02: Arithmetic Dyads Arithmetic Monads
ndexOfLast
ElementOf
ndicesOfOnes
FindnsertionPoint
ndexOfLargest
FindFirstTrue
ndicesWhereTrue
or <.
or :
or 0:
ary corp. or e.
or +, +., *.,
resu1t resu1t
Fork Hook
|l 1 |s j:
|ls oulpul
|s or|lled
g
{ 1 h )
x y
{ 1
g )
x y
Selections
1 0 2 # 'abc'
11 0 2 # 'abc'
11 0 2 #!.'*' 'abc'
1 0 1&#^:_1 'ab'
1 0 1&#^:_1!.'*' 'ab'
Copy
CopyFill
CopyCustom
Expand
ExpandCustom
acc
a cc
a*cc
a b
a*b
abcd
is e1gh
k1
mnop
mnop
e1gh
temsFrom _1 1 { ^
From (0r|lled
ear|y ax|s)
ca
ge
k
om
{<a:,2 0) { ^
bd
1h
1
np
FromEachRow 1 2 {"1 ^
FromUnboxed
(Fasl lorr)
1o
{<"1j { ) ^
1 1
2 2
Monads
&
. 2
0 1 2
. _2
2 1 0
. 2 2
0 1 2
2 4 S
: 2
_2 _1 0 1 2
From
(A|| axes sca|ar)
2 1 { ^
From (0r|lled
lra|||rg ax|s)
e1gh
mnop
1 2 { ^
Whole-Array Operations
|. 'abcde'
2 |. 'abcde'
_2 |. 'abcde'
2 |.!.'*' 'abcde'
|.!.'*' 'abcde'
Reverse
RotateLeft
RotateRight
ShiftLeft
ShiftRightOne
edcba
cdeab
deabc
cde**
*abcd
,: 2 1 4 1
,:~ 2 1 4 1
'abcd' ,: 2 1 4 1
,:,: 2 1 4 1
GradeUp*
SortUp*
SortUpUsing*
Ordinals*
1 2 0 2
1 1 2 4
bdac
2 0 2 1
he1g
1k
pmno
dabc
1 _1 |. Rotate
(ru|l|ax|s)
abcd
e1gh
k1
mnop
aem
b1n
cgko
dh1p
|: Transpose
(reverse axes)
abcd
e1gh
k1
mnop
x |: y ReorderAxes
(roves axes x lo erd ol axes)
'c0 c1 c2' =. |: y AssignndividualColumns
abcd
e1*h
k1
mnop
Amend '*' {<1 2))
abcd
e1gh
k1
mnop
ab
e1
*+
mn
Amend
(gerurd lorr)
'*+' j`{#j)` )
ab
e1
mn
y =. x m) y AmendnPlace (lasl lorr)
use \: lor descerd|rg order
1oin and Reshape
abcd , Enfile
ab
cd
0 1
2 2
0 1
Reshapetems 2 $
0 1
2 2
'ab' , 'cd' Append abcd
0 1
2 2
8 9
Append
(urequa| rar|s)
, 8 9
0 1
2 2
0 1
2 2
8 0
Append
(srorl)
, ,8
0 1
2 2
0 1
2 2
8 8
Append
(alor)
, 8
0 1
2 2
,. 'ab' Enfiletems
a
b
'ab' ,. 'cd' Appendtems
ac
bd
$ ,: 'ab' temize
(adds |ead|rg ax|s)
1 2
'ab' ,: 'cd' Laminate
ab
cd
0 1 2 Reshape 2 {$,)
0 1
2 2
2 , {4 , S) Link 2 4 S
2 ,&< {4 , S) JoinBoxed 2 4 S
0 1
2 2
4 0
6 6
Raze (expard |lers
ol opered ooxes lo s|ze
ol |argesl, lrer apperd)
,
0 1
2 2
,4 6
,: '2 wds' JWords 2 wds
,:^:_1 w1 w2 RazeWords w1 w2
Operations on Booleans
+.
+:
OR
NOR
*.
*:
AND
NAND
~:
=
XOR
XNOR
m b.
(0m<16) 8oo|ear lurcl|or W|lr lrulr lao|e
2 2#:4 4#:m (1 b. |s AN0)
16b1a Base16 constant 26
Dyads: Monad: -. NOT
> < >: <: are a|so rear|rglu|.
m b.
(16m<32) bitwise 8oo|ear; app||es
{m-16) b. lo eacr o|l ol |rlegers
Take and Drop
2 {. . 6
_2 {. . 6
2 ). . 6
_2 ). . 6
4 {. 2 2
4 {.!.9 {2 2)
Take
TakeLast
Drop
DropLast
Overtake
OvertakeCustom
0 1
4 S
2 2 4 S
0 1 2 2
2 2 0 0
2 2 9 9
2 _2 {. . 4 4 TakeMultiAxis
2 2
6 7
{. 0 1 2
{: 0 1 2
). 0 1 2
): 0 1 2
Head
Tail
Behead
Curtail
0
2
1 2
0 1
x 22 b. y x 22 b. y x 24 b. y
rolale y |ell x o|ls urs|gred s|gred
sr|ll y |ell (x>0) or r|grl (x<0) x o|ls
Box Operations
l. 8 Level 2
# S:0 8 Spread 2 2 2 2 1
1 {:: 8 Fetch 6 7
8 is 0 1 2 2 4 S 6 7 8
$ l:0 8 AtLevel ,2 ,2 ,2 ,2_
0 1 {:: 8 Fetch 2 2
|. &.> 8 Each (lasl) 4 S 2 2 0 1 7 6 8
{. l:1 8 AtLevel 0 1 6 8
0 2 0 {:: 8 FetchList 4 S 0 1
J Reference Card for version 6.02
From (Ax|s 1
Corp|ererlary)
e1h
1 2 { ^
From (0erera|
axes)
1eg
nmo
1 2 1 0 2 { ^
Matrix Operations
x. y
x x. y
x +, .* y
-, .* y
+, .* y
Matrixnverse
MatrixDivide
MatrixMultiply
Determinant
Permanent
Complex Numbers
2x1
1p2
+ 24
+. 24
*. 24
| 24
. 12
2 . 4
r. 1r2p1
2 r. 1p1
ExpNum
CircNum
Conjugate
Realmag
LenAngle
Magnitude
TimesJ
Complex
Cis (^. y)
TimesCis
2*e
1
1*n
2
2_4
2 4
S 0.927
S
_21
24
0.S0.87
_20
Insert
u, y
u, 1 2 S
+, 1 2 S
+,\ 1 2 S
+,\. 1 2 S
m, y
lrserl u oelWeer |lers ol y
nsert
Sum
RunningSum
RevRunningSum
lrserl veros lror gerurd m
1 u 2 u S
9
1 4 9
9 8 S
Mathematics
^. 2 0 1
4 ^. 'abc'
C. 2 1 0
1 2 0 C. 'abc'
C.!.2 =,~ 0 1
p: 2
x p: y
q: S6
_ q: S6
Anagramndex
Anagram
PermForm
Permute
PermParity
YthPrime
Primenfo
PrimeFactors
PrimeExps
4
cab
1 2 0
cba
_1 1
7
various
2 2 2 7
2 0 0 1
x: 1x2
x:^:_1 {1r2)
2 x: 1r2
Exact
nexact
NumDenom
1r2
0.2222
1 2
__ q: S6 PrimeFacExp
2 7
2 1
Trigonometry and Calculus
1 o. 1r2p1
2 o. 1r2p1
2 o. 1r2p1
other o. y
o. 1
p. 6 S 1
p. 1 _2 _2
6 S 1 p. 2
1 _2 _2 p. 2
p.. 6 S 1
6 p.. S 2
*: d. 1
*: 0. 1
*:`+: 0. 1
1e_8 u 0: n y
^ t. 1 2 2
u`v t. n
^ t: 1 2 2
^ 1. 2
m u. n
Sin
Cos
Tan
Trig Functions
PiTimes
Roots
Coeffs
EvalPoly
EvalPoly
PolyDeriv
Polyntegral
Derivative
PartialDeriv
AssignDeriv
SecantSlope of nth derivative
TaylorCoeff
AssignTaylor
ExpTaylor
TaylorApprox
HypergeometricSeries
0.866
0.S
1.722
2.1416
1 _2 _2
6 S 1
20
20
S 2
6 S 1
+:
1 0.S 0.167
1 1 1
1 1 0.S&p.
Gerunds
u`v
u`''
TwoVerbGerund
OneVerbGerund
+:`*: `:0 . 2
0 2 4
0 1 2
Apperd vero
resu|ls
+
0 6 2
+`'' `:6
`!`-.* 0 2 _2
MakeVerb
Agenda*
". '2 + 2'
u b. y
u M.
2!:0 y
2!:1 y
2!:2 y
x 2!:4 nty
x 2!:S 11oaty
4!:0 <'name'
S!:S <'name'
6!:0 ''
x 6!:2 'sentence'
7!:2 'sentence'
Execute sentence
nfo on u: y=_1 inverse; 0 ranks; 1 identity function
Memoize: u, but saving results for possible reuse
Datatype of y
Binary representation of y as coded character string
Binary representation of y as displayable hex array
Numeric/bytestring conversion. x>0: corverl ||sl y lo crar ||sl,
2^x (|rl) or 2^>:x (l|oal) crars/ruroer.
x<0: corverl crar ||sl y lo rurer|c ||sl, 2^-x (|rl) or
2^>:-x (l|oal) crars/ruroer. x=0: 2-oyle srorl lo urs|gred |rl
Class of name, _1 if undefined
String which, if interpreted, creates the value of name
Current time Y M D H M S
Average execution time of sentence over x samples
Space to execute sentence
Selected Foreigns & Miscellaneous
S
$. Sparse matrix $: Recursion s: Symbol u: Unicode a. Alphabet
u~ y
x u~ y
x u^:n y
x u^:v y
x u^:v y
u^:_
x u^:v^:_ y
u^:a:
{~^:a:&0
u :.v
u ::v
x uv y
x u:v y
1 2 +,* 2 4
1 2 +,:* 2 4
x u&:v y
x u&v y
x u&.:v y
x u&.v y
>:&. > 1 2 2
>:&.:> 1 2 2
m&v y or u&n y
x m&v y
Reflexive y u y
Passive y u x
Power execule x&u lor n l|res; |l n<0, execule
|rverse ol x&u lor -n l|res; |l n=0, resu|l |s y
Power Wrere n |s g|ver oy x v y
f y |l x v y |s la|se(0),
x u y |l x v y |s lrue(1)
Converge repeal u url|| resu|l |s corslarl
DoWhile repeal u Wr||e x v y |s 1
ConvergeHistory repeal u url|| resu|l |s corslarl,
relurr a|| |rlerred|ale va|ues
ChaseChain lo||oW cra|r ol record pos|l|ors
nverse |||e u, oul |rverse |s v
Adverse u, oul execule v |l error dur|rg u
Atop x u:v"v y
At u x v y
Atop 2 8 u8. {+, 1*2) , {+, 2*4)
At 11 u8. +, 1 2 * 2 4
Appose {v x) u v y
Compose* x u&:v"mv y
Dual v^:_1 {v x) u v y
Dual* x u&.:v"mv y
2 2 4
2 2 4
MonadFromDyad m v y or y u n
sare as (m&v) ^:x y (x u&n y s|r||ar|y)
Adverbs and Conjunctions
mv |s rorad|c rar| ol v
F
o
r
m
a
t 99 ". '2 S.S xx'
S2 ": 1.468 2.2
7_2 ": 2.2
'njC84.' 8!:2 2 _S
Numbers
Format
Format
Format
2 S.S 99
1.47 2.20
2.20e0
2 SC8
Shape and Rank
$ . 2 2
# . 2 2
#$ . 2 2
ShapeOf
TallyOf
RankOf
2 2
2
2
+, 2 4
0 1
2 2
+,"1 1 S
0 1
2 2
+,"0
0 1
2 2
0 1
2 2
1 2 +,"0
1 2 2
S 6 7
0 1 2
2 4 S
1 2 2 +,"1
1 2 S
4 6 8
0 1 2
2 4 S
1 2 2 +,"0
1ength
error
0 1 2
2 4 S
x u, y app||es u oelWeer eacr ce||
ol x ard a|| ol y
u.v (rar| v) |s x {{x v y){u)`:6 y
Control Structures
1. 1 do. 80 eLse. 81 end.
1. 1 do. 80 e1se1. 11 do. 81 e1se1. 12 do. 82 end.
returnresuLt return.
or|lled 1 |s lrue
,._1 or|ls lre l|rsl, ard ,._2 lre |asl, |ler |r eacr parl|l|or.
Partitions
\ . 2
2 \ . 4
_2 \ . S
\. . 2
2 \. . S
_2 \. . S
Prefixes
nfixes
nfixes, ro over|ap
Suffixes
Outfixes
Outfixes, ro over|ap
,0 0 1 0 1 2
0 1 1 2 2 2
0 1 2 2 ,4
0 1 2 1 2 ,2
2 4 0 4 0 1
2 4 0 1 2
,.1 'peop1e'
,.2 'peop1e'
0 1 0 1 ,.1 . 4
0 1 0 1 ,.2 . 4
'peop1e' ,. . 6
CutOnHead
CutOnTail
CutStartAtOne
CutEndAtOne
Key
peo p1e
pe op1e
1 2 ,2
0 1 2 2
0 2 1 S ,2 ,4
abcde1gh
k1mnop
qrstuvwx
yz01224S
6789^8C0
LI6u1Jkl
Mu0q8S1
,.2
2 4
2 2
app||ed lo
SubArrays
(a|| sraded)
,._2
2 4
2 2
app||ed lo
FullSubArrays
(sradedoorder)
abcde1
ghk1
mnopqr
stuvwx
,.0
1 _2
2 2
app||ed lo
SubArray
(sraded)
C
o
p
y
r
i
g
h
t
2
0
0
9
H
H
R
i
c
h
,
R
G
S
h
e
r
l
o
c
k
2
0
0
9
/
0
2
/
0
1
Constants
1^8
lI
II
C8
C8lI
0Ll
9{a.
10{a.
12{a.
12{a.
127{a.
tab
line feed
form feed
carriage return
CR LF pair
delete (de||r|ler)