aboutsummaryrefslogtreecommitdiff
path: root/spec/reference.bqn
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-12-21 16:55:41 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-12-21 16:55:41 -0500
commita3070d80876b8480a3ee5c423cc3372b3d175a99 (patch)
tree011ea8241ea73f72d54f80e59609a9c323c73578 /spec/reference.bqn
parente3174f1a67e626b6ebfe8889a466cc9630eea3a5 (diff)
Define Rank function in reference.bqn
Diffstat (limited to 'spec/reference.bqn')
-rw-r--r--spec/reference.bqn14
1 files changed, 9 insertions, 5 deletions
diff --git a/spec/reference.bqn b/spec/reference.bqn
index b7a8f1cd..a3b9046b 100644
--- a/spec/reference.bqn
+++ b/spec/reference.bqn
@@ -15,14 +15,14 @@
# LAYER 0: Assumed functionality
# IEEE 754, except NaN results cause an error and -0 is converted to 0.
-# LIMITED to the stated cases and real number arguments.
+# LIMITED to the stated cases and atomic arguments.
+ # Add
- # Negate Subtract
× # Multiply
÷ # Reciprocal Divide
⋆ # Exponential Power
⌊ # Floor
-= # Rank Equals
+= # Equals
≤ # Less Than or Equal to
# Other basic functionality that we need to assume
@@ -53,6 +53,8 @@ Type # Unit (enclosed) prototype of 𝕩
⊸ ← {(𝔽𝕨⊣𝕩)𝔾𝕩}
⟜ ← {(𝕨⊣𝕩)𝔽𝔾𝕩}
+≢ ↩ IsArray◶⟨⟩‿≢ # LIMITED to monadic case
+
# LIMITED to numeric arguments for arithmetic cases
√ ← 2⊸√ ⊘ (⋆⟜÷˜)
∧ ← ×
@@ -62,15 +64,18 @@ Type # Unit (enclosed) prototype of 𝕩
< ← {⟨⟩⥊⟨𝕩⟩} ⊘ (¬≤˜)
> ← (¬≤)
≥ ← !∘0 ⊘ (≤˜)
-≠ ← Length ⊘ (¬∘=)
+≠ ← Length ⊘ (¬=)
+= ↩ Rank ⊘ =
× ↩ 0⊸(<->) ⊘ ×
⌊ ↩ ⌊ ⊘ {(𝕨>𝕩)⊑𝕨‿𝕩}
⌈ ← -∘⌊∘- ⊘ {(𝕨<𝕩)⊑𝕨‿𝕩}
-≢ ↩ IsArray◶⟨⟩‿≢ # LIMITED to monadic case
¨ ← _eachm # LIMITED to monadic case and array 𝕩
´ ← _fold
+Rank ← 0⊑≢∘≢
+Length ← (0<Rank)◶⟨1⋄0⊑≢⟩
+
_eachm←{
r←⥊𝕩 ⋄ F←𝔽
E←(≠r)⊸≤◶{r↩r𝕩_amend˜F𝕩⊑r⋄E𝕩+1}‿⊢
@@ -83,7 +88,6 @@ _fold←{
{r↩(𝕩⊑v)F r}¨(l-1)⊸-¨↕l
r
}
-Length ← (0<=)◶⟨1⋄0⊑≢⟩
#⌜