| Head | {. _ 1 _ | Take |
{.y selects the leading item of y , or an
item of fills if y has no items; that is, {.y
↔ 0{1{.y .
Thus:
a=: i. 3 2 3
a;({.a);({."2 a);({."1 a)
+--------+-----+--------+-----+
| 0 1 2|0 1 2| 0 1 2| 0 3|
| 3 4 5|3 4 5| 6 7 8| 6 9|
| | |12 13 14|12 15|
| 6 7 8| | | |
| 9 10 11| | | |
| | | | |
|12 13 14| | | |
|15 16 17| | | |
+--------+-----+--------+-----+
]b=: ;/a
+-----+-------+--------+
|0 1 2|6 7 8|12 13 14|
|3 4 5|9 10 11|15 16 17|
+-----+-------+--------+
{.&> b
0 1 2
6 7 8
12 13 14
{. i.0 3
0 0 0
|
If x is an atom, x{.y takes
from y an interval of |x items; beginning at the front
if x is positive, ending at the tail if it is negative. In an overtake (in which the number to be taken exceeds the number of items), extra items consist of fills; zeros if y is numeric, a: if it is boxed, spaces if literal, and s: ' ' if symbol. The fill atom f is also specified by fit, as in {.!.f . In general, if y is not an atom, x may be a list of length not more than $$y , and if y is an atom, it is replaced by ((#x)$1)$y . Element k produces (k{x){."(($$y)-k) y ; an infinite value is replaced by the length of the corresponding axis. |
y=: i. 3 4
y;(2{.y);(5{.y);(_5{.y);(_6{.'abcd');(2 _3{.y)
+---------+-------+---------+---------+------+-----+
|0 1 2 3|0 1 2 3|0 1 2 3|0 0 0 0| abcd|1 2 3|
|4 5 6 7|4 5 6 7|4 5 6 7|0 0 0 0| |5 6 7|
|8 9 10 11| |8 9 10 11|0 1 2 3| | |
| | |0 0 0 0|4 5 6 7| | |
| | |0 0 0 0|8 9 10 11| | |
+---------+-------+---------+---------+------+-----+
2 {."1 y
0 1
4 5
8 9
_ 2 {. y
0 1
4 5
8 9
6{.'ab';'cde';'fghi'
+--+---+----++++
|ab|cde|fghi||||
+--+---+----++++