From 66272177ff5d3cf64ef2371d9a16612c4019a9b2 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 25 Oct 2021 21:34:35 -0400 Subject: =?UTF-8?q?Add=20=E2=8B=88=20(Enlist/Pair)=20to=20specification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/spec/primitive.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/spec/primitive.html') diff --git a/docs/spec/primitive.html b/docs/spec/primitive.html index f4cf08d9..cb03f6f8 100644 --- a/docs/spec/primitive.html +++ b/docs/spec/primitive.html @@ -119,7 +119,7 @@

A left argument for any of the three reduction-based modifiers indicates an initial value to be used, so that the first application of the operand function applies not to two values from 𝕩 but instead to a value from 𝕨 and a value from 𝕩. In Fold and Insert, the entire value 𝕨 is the initial value, while in Scan, 𝕨 is an array of initial values, which must have shape 1↓≢𝕩.

Repeat () applies the operand function, or its inverse, several times in sequence. The right operand must consist only of integer atoms (arranged in arrays of any depth), and each number there is replaced with the application of the left operand that many times to the arguments. If a left argument is present, then it's reused each time, as if it were bound to the operand function. For a negative number -n, the function is "applied" -n times by undoing it n times. In both directions, the total number of times the function is applied is the maximum of all numbers present: results must be saved if intermediate values are needed.

Restructuring

-

Enclose (<) forms a unit array that contains its argument.

+

Enclose (<) forms a unit array that contains its argument. Enlist and Pair () form a 1- or 2-element list of all arguments, that is, 𝕩 or 𝕨,𝕩.

Merge (>) combines the outer axes of an array of arrays with inner axes: it requires that all elements of its argument have the same shape, and creates an array such that (ij)⊑>𝕩 is ij𝕩. It also accepts atom elements of 𝕩, converting them to unit arrays, or an atom argument, which is returned unchanged. Solo and Couple () turn one or two arguments into major cells of the result and can be defined easily in terms of Merge.

Join To () combines its two arguments along an existing initial axis, unless both arguments are units, in which case it creates an axis and is identical to Couple (). The arguments must differ in rank by at most 1, and the result rank is equal to the maximum of 1 and the higher argument rank. Each argument with rank less than the result, and each major cell of an argument with rank equal to it, becomes a major cell of the result, with cells from the left argument placed before those from the right. Join () generalizes the equal-rank subset of this behavior to an array of values instead of just two. The argument must be an array (unlike Merge), and its elements must all the same rank, which is at least the argument rank. Atom elements are treated as unit arrays. Then "outer" argument axes are matched up with leading "inner" element axes, and elements are joined along these axes. In order to allow this, the length of an element along a particular axis must depend only on the position along the corresponding axis in the argument. An empty argument to Join is return unchanged, as though the element rank is equal to the argument rank.

Deshape () differs from the provided function (which returns the element list of an array) only in that it accepts an atom, returning a one-element list containing it. Reshape () is extended in numerous ways. It accepts any list of natural numbers (including as a unit array or atom) for the left argument and any right argument; 𝕩 is deshaped first so that it is treated as a list of elements. These elements are repeated cyclically to fill the result array in ravel order. If 𝕩 is empty then a non-empty requested result shape causes an error. Furthermore, at most one element of 𝕨 can be a "length code": one of the primitives ⌊⌽↑. In this case, a target length is computed from the number of elements in 𝕩 divided by the product of the other elements of 𝕨 (which must not be zero). If the target length is an integer then it is used directly for the length code. Otherwise, an error is given if the length code is , and the target length is rounded down if the code is and up if it's or . With code , elements are repeated cyclically as usual, but with code , the extra elements after each argument element is used are fill values for 𝕩.

-- cgit v1.2.3