aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-02-15 19:57:36 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-02-15 19:57:36 -0500
commit4fd3566067b123ba53e0923520bdc8e19fad7d83 (patch)
tree720e25472680515fe9882b809f64b6acd1fe3391 /spec
parent666ad23844be33141f7c986de3b83f035db4b95a (diff)
Fix specification for Group Indices
Diffstat (limited to 'spec')
-rw-r--r--spec/primitive.md6
-rw-r--r--spec/reference.bqn2
2 files changed, 4 insertions, 4 deletions
diff --git a/spec/primitive.md b/spec/primitive.md
index 2662f8c4..95fd9392 100644
--- a/spec/primitive.md
+++ b/spec/primitive.md
@@ -153,6 +153,8 @@ A left argument for any of the three reduction-based modifiers indicates an init
Each element in an array `s⥊e` is associated with an *index*, which is a list of natural numbers `i` such that `∧´i<s`. The list of all indices, which corresponds to the element list `e`, contains all such lists `i` in lexicographic order. That is, index `i` comes before `j` exactly when the two indices are not the same, and `i` has the smaller value at the first position where they are unequal. The index of an element along a particular axis `a` is the value `a⊑i`.
+**Range** (`↕`) is extended to apply to a list of natural numbers, in addition to the provided case of a single natural number (an enclosed natural number `𝕩` should still result in an error). For a list `𝕩`, the result is an array of shape `𝕩` in which the value at a given index is that index, as a list of natural numbers. That is, `i≡i⊑↕𝕩` for any list of natural numbers `i` with `∧´i<𝕩`.
+
**Pick** (`⊑`) is extended to array left arguments. In this case, it requires every depth-1 array in the nested structure of `𝕨` to be a valid index list for `𝕩`, and every atom to be contained in one of these lists. The result is `𝕨` with each index list replaced by the element of `𝕩` at that index. In the simple case where `𝕨` itself is an index list, the result is the element of `𝕩` at index `𝕨`.
**First** (`⊑`) simply takes the first element of its argument in index order, or the fill element if `𝕩` is empty.
@@ -161,9 +163,7 @@ For **Select** (`⊏`), `𝕨` is an array of natural numbers, or a list of such
**First Cell** (`⊏`) selects the initial major cell of `𝕩`, giving an error if `𝕩` has rank 0 or length 0.
-**Group** (`⊔`) performs an opposite operation to Select, so that `𝕨` specifies not the argument index that result values come from, but the result index that argument values go to. The general case is that `𝕨` is a list of arrays of numbers; if it has depth less than 2 it's converted to this form by first enclosing it if it's an atom, then placing it in a length-1 list. After this transformation, the result rank is `≠𝕨`, and each result element has rank `(≠𝕨)+(=𝕩)-+´=¨𝕨`, with the initial `≠𝕨` axes corresponding to elements of `𝕨` and the remainder to trailing axes of `𝕩`. Each atom in `𝕨` can be either a natural number or `¯1` (which indicates the corresponding position in `𝕩` will be omitted). If `¯1` doesn't appear, the result has the property that each cell of `𝕩` appears in the corresponding element of `𝕨⊏𝕨⊔𝕩`. More concretely, the length of the result along axis `a` is the maximum value in `a⊑𝕨` plus one, or zero if `a⊑𝕨` is empty. Axis `a` corresponds to `=a⊑𝕨` axes in `𝕩`, and an element of the result at position `i` along this axis contains all positions in `𝕩` where `i=a⊑𝕨`. There may be multiple such positions, and they're arranged along axis `a` of that result element according to their index order in `𝕩`. The shapes of components of `𝕨` must match the corresponding axes of `𝕩`, except for rank-1 components of `𝕨`, which can match or have an extra element. This element, which like the others is either a natural number or `¯1`, gives the minimum length of the result axis corresponding to the component of `𝕨` in question, but otherwise does not affect the result. **Group Indices** treats its argument `𝕩` as a left argument for Group and uses a right argument made up of indices, with the definition `⊔⟜(↕≠⚇1)`.
-
-**Range** (`↕`) is extended to apply to a list of natural numbers, in addition to the provided case of a single natural number (an enclosed natural number `𝕩` should still result in an error). For a list `𝕩`, the result is an array of shape `𝕩` in which the value at a given index is that index, as a list of natural numbers. That is, `i≡i⊑↕𝕩` for any list of natural numbers `i` with `∧´i<𝕩`.
+**Group** (`⊔`) performs an opposite operation to Select, so that `𝕨` specifies not the argument index that result values come from, but the result index that argument values go to. The general case is that `𝕨` is a list of arrays of numbers; if it has depth less than 2 it's converted to this form by first enclosing it if it's an atom, then placing it in a length-1 list. After this transformation, the result rank is `≠𝕨`, and each result element has rank `(≠𝕨)+(=𝕩)-+´=¨𝕨`, with the initial `≠𝕨` axes corresponding to elements of `𝕨` and the remainder to trailing axes of `𝕩`. Each atom in `𝕨` can be either a natural number or `¯1` (which indicates the corresponding position in `𝕩` will be omitted). If `¯1` doesn't appear, the result has the property that each cell of `𝕩` appears in the corresponding element of `𝕨⊏𝕨⊔𝕩`. More concretely, the length of the result along axis `a` is the maximum value in `a⊑𝕨` plus one, or zero if `a⊑𝕨` is empty. Axis `a` corresponds to `=a⊑𝕨` axes in `𝕩`, and an element of the result at position `i` along this axis contains all positions in `𝕩` where `i=a⊑𝕨`. There may be multiple such positions, and they're arranged along axis `a` of that result element according to their index order in `𝕩`. The shapes of components of `𝕨` must match the corresponding axes of `𝕩`, except for rank-1 components of `𝕨`, which can match or have an extra element. This element, which like the others is either a natural number or `¯1`, gives the minimum length of the result axis corresponding to the component of `𝕨` in question, but otherwise does not affect the result. **Group Indices** treats its argument `𝕩` as a left argument for Group and uses a right argument made up of indices, which is `↕≠𝕩` if `𝕩` has depth 1 and `↕∾≢¨𝕩` if it has depth 2. Because the depth-1 case uses atomic indices, `𝕩` is required to be a list (and it can't be an atom). Much like Range, the result has depth one higher than the argument.
**Indices** (`/`) applies to a list of natural numbers, and returns a list of natural numbers. The result contains `i⊑𝕩` copies of each natural number index `i` for `𝕩`, in increasing order.
diff --git a/spec/reference.bqn b/spec/reference.bqn
index 988bfb51..c3719144 100644
--- a/spec/reference.bqn
+++ b/spec/reference.bqn
@@ -354,7 +354,7 @@ Replicate ← {0<=𝕨}◶(⥊˜⟜≠Rep⊢)‿{!𝕨=○≠𝕩⋄𝕨Rep𝕩}
# LAYER 6: Everything else
∾ ↩ Join ⊘ JoinTo
-⊔ ← ⊔⟜(↕≠⚇1) ⊘ Group
+⊔ ← GroupInds ⊘ Group
⍉ ← Transpose ⊘ ReorderAxes
⊐ ← ⍷⊸⊐ ⊘ IndexOf
∊ ← MarkFirst ⊘ (⊐˜<≠∘⊢)