| Catalogue | { 1 0 _ | From |
{y forms a catalogue from the atoms of its argument,
its shape being the chain of the shapes of the opened items
of y . The common shape of the boxed results
is $y . For example:
{ 'ht';'ao';'gtw'
+---+---+---+
|hag|hat|haw|
+---+---+---+
|hog|hot|how|
+---+---+---+
+---+---+---+
|tag|tat|taw|
+---+---+---+
|tog|tot|tow|
+---+---+---+
The Cartesian product is readily defined in terms
of { , thus:
CP=: {@(,&<)
0 1 CP 2 3 4
+---+---+---+
|0 2|0 3|0 4|
+---+---+---+
|1 2|1 3|1 4|
+---+---+---+
|
If x is an integer in the range from -n=: #y
to n-1 , then x{y selects item n|x
from y . Thus:
2 0 _1 _3 { 'abcdefg'
cage
t=:3 4$'abcdefghijkl'
1{t
efgh
More generally, >x may be a list whose successive
elements are (possibly) boxed arrays that specify selection along
successive axes of y .Finally, if any r=:>j{>x used in the selection is itself boxed, selection is made by the indices along that axis that do not occur in >r . Note that the result in the very last dyadic example, that is, (<<<_1){m , is all except the last item. |
t=: 3 4 $ 'abcdefghijkl'
t; (1{t); (2 1{t); (1{"1 t); ((,1){"1 t); (2 1{"1 t)
+----+----+----+---+-+--+
|abcd|efgh|ijkl|bfj|b|cb|
|efgh| |efgh| |f|gf|
|ijkl| | | |j|kj|
+----+----+----+---+-+--+
t; (2 0{t); ((<2 0){t); ((2 0;1 3){t); ((<2 0;1 3){t)
+----+----+-+--+--+
|abcd|ijkl|i|ih|jl|
|efgh|abcd| | |bd|
|ijkl| | | | |
+----+----+-+--+--+
(_1{m); (_1{"2 m); (_1{"1 m); (<<<_1){m=:i.2 3 4
+-----------+-----------+--------+---------+
|12 13 14 15| 8 9 10 11| 3 7 11|0 1 2 3|
|16 17 18 19|20 21 22 23|15 19 23|4 5 6 7|
|20 21 22 23| | |8 9 10 11|
+-----------+-----------+--------+---------+