aboutsummaryrefslogtreecommitdiff
path: root/spec/primitive.md
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-02-08 21:58:36 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-02-08 21:58:36 -0500
commit54d28433b31af8bbd9c0ab3af7a46a4fcab6750b (patch)
tree92413a7ce2963b117e11ca274621a16733d2a2cb /spec/primitive.md
parentd46f86d31d8d90145da0f32aff611ec576cbd11b (diff)
Explicitly describe iteration order for Each and similar modifiers
Diffstat (limited to 'spec/primitive.md')
-rw-r--r--spec/primitive.md2
1 files changed, 2 insertions, 0 deletions
diff --git a/spec/primitive.md b/spec/primitive.md
index 24f98e6d..85237526 100644
--- a/spec/primitive.md
+++ b/spec/primitive.md
@@ -123,6 +123,8 @@ Arithmetic functions not already provided are defined in layer 1. These definiti
Modifiers for iteration are defined in layers 1, 2, and 4. Two 2-modifiers, `⚇` and `⎉`, use a list of numbers obtained by applying the right operand to the arguments in order to control application. This list has one to three elements: if all three are given then they correspond to the monadic, left, and right arguments; if one is given then it controls all three; and if two are given then they control the left argument, and the right and monadic arguments.
+The iteration modifiers `⌜¨⚇˘⎉` process elements or cells in index order, that is, according to lexicographic ordering of indices or according to simple numeric ordering of the indices in the Deshaped (`⥊`) arguments. When both arguments are mapped over independently, the left argument is mapped over "first", or as an outer loop: one part of the left argument is paired with each part of the right in turn, then the next part of the left argument, and so on.
+
**Table** (`⌜`) and **Each** (`¨`) map over the elements of arrays to produce result elements. They convert atom arguments to unit arrays. With one argument, the two modifiers are the same; with two, they differ in how they pair elements. Table pairs every element of the left argument with every element of the right, giving a result shape `𝕨∾○≢𝕩`. Each uses leading axis agreement: it requires one argument's shape to be a prefix of the other's (if the arguments have the same rank, then the shapes must match and therefore be mutual prefixes). This causes each element of the lower-rank argument to correspond to a cell of the higher-rank one; it's repeated to pair it with each element of that cell. The result shape is the shape of the higher-rank argument.
**Depth** (`⚇`) is nearly a generalization of Each: `¨` is equivalent to `⚇¯1`, except that `⚇¯1` doesn't enclose its result if all arguments are atoms. The list given by the right operand specifies how deeply to recurse into the arguments. A negative number `-n` means to recurse `n` times *or* until the argument is an atom, while a positive number `n` means to recurse until the argument has depth `n` or less. Recursion continues until all arguments have met the criterion for stopping. This recursion is guaranteed to stop because arrays are immutable, and form an inductive type.