apl>" <-APL2-------------------- sam268.txt ---------------------------->
apl>" <- Test of syntax error ------------------------------------------>
apl>text# 'z#test r '
apl>text#text,[ .5]'Rz(,'',''F`=z) '
apl>text#text,[1] 'L # z # 1 0 1 `Z ''abc'''
apl>Lfx text
test
apl>test 1
Rz(,','F`=z)
^ 70 - missing right argument during execute.
The error occurred in function test
test[1]
apl>)si
test[1] *
apl>" <- Partition (`Z) p 188 ------------------------------------------>
apl>)load cap2/help/help
test 1
^ 998 - end of apl processing.
cap2/help/help.apl
^ loaded.
entering e.g. help 'R' tells you what the R key does.
entering e.g. help 'reshape' tells you about the reshape function.
apl>display 1 1 2`Z'abc'
+$---------+
| +$-+ +$+ |
| |ab| |c| |
| +--+ +-+ |
+E---------+
apl>L # z # 1 1 2 `Z 'abc'
ab c
apl>(`=z),Rz
2 2
apl>L # z # 1 0 1 `Z 'abc'
a c
apl>(`=z),Rz
2 2
apl>display z
+$--------+
| +$+ +$+ |
| |a| |c| |
| +-+ +-+ |
+E--------+
apl>" <- Partition (`Z) p 188 Lengths of arguments must match ---------->
apl>L # z # 1 0 1 `Z 'abcd'
L # z # 1 0 1 `Z 'abcd'
^ 128 - length error.
apl>(`=z),Rz
2 2
apl>display z
+$--------+
| +$+ +$+ |
| |a| |c| |
| +-+ +-+ |
+E--------+
apl>" <- Partition (`Z) p 188 Partition numeric vector into pieces ----->
apl>L # z # 2 1 2 `Z 10 20 30
10 20 30
apl>(`=z),Rz
2 2
apl>display z
+$-------------+
| +$----+ +$-+ |
| |10 20| |30| |
| +~----+ +~-+ |
+E-------------+
apl>" <- Partition (`Z) p 189 Partition adds a level of nesting -------->
apl>L # z # 'one' 'two' 'buckle my shoe'
one two buckle my shoe
apl>(`=z),Rz
2 3
apl>L # z # 1 1 2 `Z z
one two buckle my shoe
apl>(`=z),Rz
3 2
apl>display z
+$-------------------------------------+
| +$------------+ +$-----------------+ |
| | +$--+ +$--+ | | +$-------------+ | |
| | |one| |two| | | |buckle my shoe| | |
| | +---+ +---+ | | +--------------+ | |
| +E------------+ +E-----------------+ |
+E-------------------------------------+
apl>" <- Partition (`Z) p 189 Examples with blank delimiters ----------->
apl>L # x # ' a stitch in time '
a stitch in time
apl>(`=x),Rx
1 22
apl>" <- Partition (`Z) p 189 Partition and discard blank delimiters --->
apl>L # z # (' ' ^= x) `Z x
a stitch in time
apl>(`=z),Rz
2 4
apl>display z
+$-------------------------+
| +$+ +$-----+ +$-+ +$---+ |
| |a| |stitch| |in| |time| |
| +-+ +------+ +--+ +----+ |
+E-------------------------+
apl>" <- Partition (`Z) p 189 Keep delimiters on the ends -------------->
apl>L # z # (1 + ' ' ^= x) `Z x
a stitch in time
apl>(`=z),Rz
2 5
apl>display z
+$-------------------------------------+
| +$-+ +$-+ +$-------+ +$--+ +$------+ |
| | | |a | |stitch | |in | |time | |
| +--+ +--+ +--------+ +---+ +-------+ |
+E-------------------------------------+
apl>" <- Partition (`Z) p 189 Keep delimiters on the beginnings -------->
apl>L # z # (1 + ~ ' ' ^= x) `Z x
a stitch in time
apl>(`=z),Rz
2 5
apl>display z
+$-------------------------------------+
| +$--+ +$------+ +$---+ +$----+ +$--+ |
| | a| | stitch| | in| | time| | | |
| +---+ +-------+ +----+ +-----+ +---+ |
+E-------------------------------------+
apl>" <- Partition (`Z) p 190 Partition a matrix at blank columns ------>
apl>L # m # 3 12 R '1 10 3.1422 100 6.2833 1000 9.425'
1 10 3.142
2 100 6.283
3 1000 9.425
apl>L # z # (~ & `/ ' ' = m) `Z m
1 10 3.142
2 100 6.283
3 1000 9.425
apl>display z
+$-------------------+
U +$+ +$---+ +$----+ |
| |1| | 10| |3.142| |
| +-+ +----+ +-----+ |
| +$+ +$---+ +$----+ |
| |2| | 100| |6.283| |
| +-+ +----+ +-----+ |
| +$+ +$---+ +$----+ |
| |3| |1000| |9.425| |
| +-+ +----+ +-----+ |
+E-------------------+
apl>" <- Partition (`Z) p 192 Partition with Axis ---------------------->
apl>display n # 4 3 R I 12
+$-------+
U 1 2 3|
| 4 5 6|
| 7 8 9|
|10 11 12|
+~-------+
apl>display 1 0 1 1 `Z[1] n
+$---------------------+
U +$+ +$+ +$+ |
| |1| |2| |3| |
| +~+ +~+ +~+ |
| +$---+ +$---+ +$---+ |
| |7 10| |8 11| |9 12| |
| +~---+ +~---+ +~---+ |
+E---------------------+
apl>)off