aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/spec/primitive.html28
-rw-r--r--spec/primitive.md30
-rw-r--r--spec/reference.bqn4
3 files changed, 60 insertions, 2 deletions
diff --git a/docs/spec/primitive.html b/docs/spec/primitive.html
index f2bd43bb..118cff41 100644
--- a/docs/spec/primitive.html
+++ b/docs/spec/primitive.html
@@ -40,3 +40,31 @@
<li>Block instances are equal if they are the same instance.</li>
</ul>
<p>This means that block instance equality indicates identity in the context of mutability: two block instances are equal if any change of state in one would be reflected in the other as well. The concept of identity holds even if the blocks in question have no way of changing or accessing state. For example, <code><span class='Function'>=</span><span class='Modifier2'>β—‹</span><span class='Brace'>{</span><span class='Value'>𝕩</span><span class='Separator'>β‹„</span><span class='Brace'>{</span><span class='Value'>𝕩</span><span class='Brace'>}}</span><span class='Modifier'>˜</span><span class='String'>@</span></code> is <code><span class='Number'>0</span></code> while <code><span class='Function'>=</span><span class='Modifier'>˜</span><span class='Modifier2'>β—‹</span><span class='Brace'>{</span><span class='Value'>𝕩</span><span class='Separator'>β‹„</span><span class='Brace'>{</span><span class='Value'>𝕩</span><span class='Brace'>}}</span><span class='String'>@</span></code> is <code><span class='Number'>1</span></code>.</p>
+<h2 id="array-functionality">Array functionality</h2>
+<p>Several subsets of primitives, or dedicated operations, are used to manipulate arrays in the reference implementation.</p>
+<ul>
+<li><code><span class='Function'>IsArray</span></code> returns <code><span class='Number'>1</span></code> if the argument is an array and <code><span class='Number'>0</span></code> if it's an atom.</li>
+</ul>
+<p>The following functions translate between arrays and the two lists that define them: the shape and ravel.</p>
+<ul>
+<li><strong>Shape</strong> (<code><span class='Function'>β‰’</span></code>) returns the shape of array <code><span class='Value'>𝕩</span></code>, as a list of natural numbers.</li>
+<li><strong>Deshape</strong> (monadic <code><span class='Function'>β₯Š</span></code>) returns the ravel of array <code><span class='Value'>𝕩</span></code>, that is, the list of its elements.</li>
+<li><strong>Reshape</strong> (dyadic <code><span class='Function'>β₯Š</span></code>) returns an array with the same ravel as <code><span class='Value'>𝕩</span></code> with shape <code><span class='Value'>𝕨</span></code>. It can be assumed that <code><span class='Function'>β‰’</span><span class='Value'>𝕩</span></code> and <code><span class='Value'>𝕨</span></code> have the same product.</li>
+</ul>
+<p>The following functions manipulate lists. In these functions, a valid index for list <code><span class='Value'>l</span></code> is a natural number less than the length of <code><span class='Value'>l</span></code>.</p>
+<ul>
+<li><strong>Range</strong> gives the list of length <code><span class='Value'>𝕩</span></code> (a natural number) with value <code><span class='Value'>i</span></code> at any index <code><span class='Value'>i</span></code>.</li>
+<li><strong>Pick</strong> (<code><span class='Function'>βŠ‘</span></code>) selects the element at index <code><span class='Value'>𝕨</span></code> from list <code><span class='Value'>𝕩</span></code>.</li>
+<li><code><span class='Modifier'>_amend</span></code> returns an array identical to list <code><span class='Value'>𝕩</span></code> except that the element at index <code><span class='Value'>𝕗</span></code> is changed to <code><span class='Value'>𝕨</span></code>.</li>
+</ul>
+<h2 id="inferred-functionality">Inferred functionality</h2>
+<p>Inferred properties are specified in <a href="inferred.html">their own document</a>, not in the reference implementation.</p>
+<ul>
+<li><code><span class='Function'>Identity</span></code> gives the identity value for reduction by function <code><span class='Function'>𝕏</span></code>.</li>
+<li><strong>Undo</strong> (<code><span class='Modifier'>⁼</span></code>) gives a partial right inverse for function <code><span class='Function'>𝔽</span></code>.</li>
+<li><code><span class='Function'>Type</span></code> gives the enclose of the fill value for array <code><span class='Value'>𝕩</span></code>.</li>
+</ul>
+<h2 id="other-provided-functionality">Other provided functionality</h2>
+<ul>
+<li><strong>Assert</strong> (<code><span class='Function'>!</span></code>) causes an error if the argument is not <code><span class='Number'>1</span></code>. If <code><span class='Value'>𝕨</span></code> is provided, it gives a message to be associated with this error (which can be any value, not necessarily a string).</li>
+</ul>
diff --git a/spec/primitive.md b/spec/primitive.md
index 859bfe27..21306fef 100644
--- a/spec/primitive.md
+++ b/spec/primitive.md
@@ -44,3 +44,33 @@ Operations are split into subtypes depending on how they were created.
- Block instances are equal if they are the same instance.
This means that block instance equality indicates identity in the context of mutability: two block instances are equal if any change of state in one would be reflected in the other as well. The concept of identity holds even if the blocks in question have no way of changing or accessing state. For example, `=β—‹{𝕩⋄{𝕩}}˜@` is `0` while `=Λœβ—‹{𝕩⋄{𝕩}}@` is `1`.
+
+## Array functionality
+
+Several subsets of primitives, or dedicated operations, are used to manipulate arrays in the reference implementation.
+
+- `IsArray` returns `1` if the argument is an array and `0` if it's an atom.
+
+The following functions translate between arrays and the two lists that define them: the shape and ravel.
+
+- **Shape** (`β‰’`) returns the shape of array `𝕩`, as a list of natural numbers.
+- **Deshape** (monadic `β₯Š`) returns the ravel of array `𝕩`, that is, the list of its elements.
+- **Reshape** (dyadic `β₯Š`) returns an array with the same ravel as `𝕩` with shape `𝕨`. It can be assumed that `≒𝕩` and `𝕨` have the same product.
+
+The following functions manipulate lists. In these functions, a valid index for list `l` is a natural number less than the length of `l`.
+
+- **Range** gives the list of length `𝕩` (a natural number) with value `i` at any index `i`.
+- **Pick** (`βŠ‘`) selects the element at index `𝕨` from list `𝕩`.
+- `_amend` returns an array identical to list `𝕩` except that the element at index `𝕗` is changed to `𝕨`.
+
+## Inferred functionality
+
+Inferred properties are specified in [their own document](inferred.md), not in the reference implementation.
+
+- `Identity` gives the identity value for reduction by function `𝕏`.
+- **Undo** (`⁼`) gives a partial right inverse for function `𝔽`.
+- `Type` gives the enclose of the fill value for array `𝕩`.
+
+## Other provided functionality
+
+- **Assert** (`!`) causes an error if the argument is not `1`. If `𝕨` is provided, it gives a message to be associated with this error (which can be any value, not necessarily a string).
diff --git a/spec/reference.bqn b/spec/reference.bqn
index a3b9046b..6e88da0a 100644
--- a/spec/reference.bqn
+++ b/spec/reference.bqn
@@ -30,8 +30,8 @@ IsArray # Return 1 if 𝕩 is an array
! # 𝕩 is 0 or 1; throw an error if it's 0
β‰’ # LIMITED to monadic case
β₯Š # LIMITED to array 𝕩 and (×´𝕨)≑≒𝕩
-βŠ‘ # LIMITED to natural number 𝕩 and vector 𝕨
-_amend # {(π•—βŠ‘π•©)↩𝕨⋄𝕩}
+βŠ‘ # LIMITED to natural number 𝕨 and list 𝕩
+_amend # {π•¨Λ™βŒΎ(π•—βŠΈβŠ‘)𝕩}
↕ # LIMITED to number 𝕩
Identity # Left or right identity of function 𝕏
⁼ # Inverse of function 𝔽