apl>" <-APL2-------------------- sam325.txt ---------------------------->
apl>1 O (O 1) % 2 3 4
1 .866025 .707107
apl>"
apl>" <- disclose (`X), page 94 ---------------------------------------->
apl>L#rrr#2 3R(I4)'abcd' '****'(5 6 7 8)'efgh' 'HHHH'
1 2 3 4 abcd ****
5 6 7 8 efgh HHHH
apl>Rrrr
2 3
apl>`=rrr
2
apl>L#zzz#`Xrrr
1 2 3 4
a b c d
* * * *
5 6 7 8
e f g h
H H H H
apl>`=zzz
1
apl>Rzzz
2 3 4
apl>RRzzz
3
apl>(Rrrr),YS/(R`1(,rrr),`ZYrrr)~`ZI0
2 3 4
apl>(RRrrr)+YS/R`1R`1(,rrr),`ZYrrr
3
apl>L#yyy#`X[(RRrrr)+IRRYrrr]rrr
1 2 3 4
a b c d
* * * *
5 6 7 8
e f g h
H H H H
apl>`=yyy
1
apl>yyy`=zzz
1
apl>"
apl>" <- disclose (`X), with axis, page 96 ----------------------------->
apl>L#h#'abcd' (1 2 3 4) 'wxyz'
abcd 1 2 3 4 wxyz
apl>L#z#`X[1]h
a 1 w
b 2 x
c 3 y
d 4 z
apl>Rz
4 3
apl>`=z
1
apl>L#w#`X[2]h
a b c d
1 2 3 4
w x y z
apl>Rw
3 4
apl>`=w
1
apl>Lfx 'z#xxx demo rrr;zzz' 'zzz#`X[xxx]rrr' 'z#+/((Rzzz)[,xxx])=YS/(R`1(,rrr),`ZYrrr)~`ZI0'
demo
apl>1 demo h
1
apl>2 demo h
1
apl>Lfx 'z#zzz demo rrr' 'z#(RRzzz)=(RRrrr)+S/ER`1R`1(,rrr),`ZYrrr'
demo
apl>z demo h
1
apl>w demo h
1
apl>"
apl>" <- drop (U) with axis, page 105 ---------------------------------->
apl>L#v#3 5R'striperodeplant'
strip
erode
plant
apl>q#1 2
apl>&/,(qUv)=L#qU[IRRv]v
ode
ant
1
apl>"
apl>" <- each (`1) showing how implemented with empty argument --------->
apl>a#3 0 2R0
apl>b#1 2 3
apl>R`1,`1a b
0 3
apl>,`X0=R`1,`1a b
1 0
apl>L#c#aR`1b
.
apl>L#s#,`X(,`X0=R`1,`1a b)/R`1a b
3 0 2
apl>Rs
3
apl>`=s
1
apl>L#d#sR`Z(Ya)RYb
.
apl>c`=d
1
apl>" <- Exponential revisited. ---------------------------------------->
apl>* -2 -1 0 1 2
.13533528 0.36787944 1 2.718282 7.389056
apl>" grade up/down revisited-------------------------------------------
apl>L#b#5 3 R 4 16 37 2 9 26 5 11 63 3 18 45 5 11 54
4 16 37
2 9 26
5 11 63
3 18 45
5 11 54
apl>Wb " s/b 3 5 1 4 2
3 5 1 4 2
apl>b[Wb;]
5 11 63
5 11 54
4 16 37
3 18 45
2 9 26
apl>C'b[Wb',((-1+RRb)R';'),']'
5 11 63
5 11 54
4 16 37
3 18 45
2 9 26
apl>c#4 23 54 28 2 11 51 26
apl>c#c,4 29 17 43 3 19 32 41
apl>c#3 2 4Rc,4 23 54 28 1 25 31 16
apl>c
4 23 54 28
2 11 51 26
4 29 17 43
3 19 32 41
4 23 54 28
1 25 31 16
apl>Wc
2 1 3
apl>c[Wc;;]
4 29 17 43
3 19 32 41
4 23 54 28
2 11 51 26
4 23 54 28
1 25 31 16
apl>C'c[Wc',((-1+RRc)R';'),']'
4 29 17 43
3 19 32 41
4 23 54 28
2 11 51 26
4 23 54 28
1 25 31 16
apl>" logarithm revisited-----------------------------------------------
apl>left#1+I5
apl>right#5+I5
apl>(left@right) `= (@right)%@left
1
apl>" magnitude revisited-----------------------------------------------
apl>(|right) = (+/(9 11 O right#4j3)*2)*.5
1
apl>" Ravel with axis revisited---------------------------------------
apl>Lfx 'z#x demo r' 'z#((R,[x]r)Rr)`=,[x]r'
demo
apl>.1 demo a#2 3R'tensix'
1
apl>1.1 demo a
1
apl>2.1 demo a
1
apl>1.1 demo b#10 15 20
1
apl>2 3 demo c#3 2 4RI24
1
apl>1 2 demo c
1
apl>a#'ant' 'boar' 'cat' 'dog' 'elk' 'fox' 'gnu'
apl>b#'hen' 'ibex' 'jird' 'kite' 'lamb' 'mice'
apl>c#'nene' 'ox' 'pig' 'quail' 'rat' 'seal'
apl>L#d#4 2 3Ra,b,c,'titi' 'viper' 'wolf' 'yak' 'zebra'
ant boar cat
dog elk fox
gnu hen ibex
jird kite lamb
mice nene ox
pig quail rat
seal titi viper
wolf yak zebra
apl>1 2 demo d
1
apl>(I0) demo h#2 3RI6
1
apl>(I0) demo k#'prune' 'pear' 'fig'
1
apl>" Reduce revisited------------------------------------------------
apl>(X/r[i;]) `= (X/r#2 3RI6)[i#2]
1
apl>(+/r[i;j;]) `= (+/r#2 3 4RI24)[i#2;j#1 2]
1
apl>(+/r) `= `X+/`1`Z[RRr]r#2 3 4 5RI120
1
apl>" Examples for aplderiv.tex --------------------------------------
apl>(2 3RI6) +.X 3 2RI6
22 28
49 64
apl>+/ `1 'e' = `1 text # 'Still' 'round' 'the' 'corner' 'there' 'may' 'wait'
0 0 1 1 2 0 0
apl>+/ `1 'e' = text
0 0 1 1 2 0 0
apl>+/ `1 'e' = (' ' ^= text) `Z text#'Still round the corner there may wait'
0 0 1 1 2 0 0
apl>)off