Group 2
J symbol (left-brace-dot): {.
Monadic case:
Name: head
Rank: _ (infinite/unbounded) – applies to the entire array y
Definition (simple): {. y is the first item of y.
Definition (precise): {. y is 0{1{.y. That is, the head of y is the first item of y, which is an item of fill elements if y has no items. The fill element is 0 for numeric arrays, space for literal arrays, and empty box for box arrays.
Please also include explanations for your answers to some of the following questions:
What is the head of a list?
What is the head of a matrix?
Why is/isn't the head of a scalar itself?
What is the head of an empty matrix (e.g., 0 4$100)?
Dyadic case:
Name: take
Rank: 1 (left); _ (right) – applies to a vector on the left and the entire array on the right
Definition (scalar x): x {. y returns x items from y. If x is positive, then items are taken from the front of y. If x is negative, then the items are taken from the back of y. If x is greater than the number of items in y, then the result is y padded out with items of fill elements. The fill element is 0 for numeric arrays, space for literal arrays, and empty box for box arrays.
Definition (vector x): x {. y returns an array constructed from the elements of y indexed by taking length xi of axis i of y, where xi is the i-th element of x. The axis is taken from the front if xi is positive, and from the back is xi is negative. If xi is infinity, then xi is the length of axis i of y. Fill elements are used if xi is greater than the length of axis i of y.
Please also include explanations for your answers to some of the following questions:
What array is returned when x is positive?
What array is returned when x is negative?
What array is returned when x is greater than the number of items in y?
What array is returned when x is zero?
What array is returned when x is a vector?
What array is returned when x is infinity?