aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/r.bqn9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/r.bqn b/src/r.bqn
index 0bfd5da4..d153a53d 100644
--- a/src/r.bqn
+++ b/src/r.bqn
@@ -31,6 +31,7 @@ _fold←{
ToArray ← <⍟(1-IsArray)
Int←IsArray◶⟨⌊⊸=,0⟩
Nat←IsArray◶⟨0⊸≤×⌊⊸=,0⟩
+Cell←{(𝕨⊸+⊑𝕩˜)⌜↕(≠𝕩)-𝕨}⟜≢
∾ ← {k←≠𝕨⋄k⊸≤◶⟨⊑⟜𝕨⋄-⟜k⊑𝕩˜⟩⌜↕k+≠𝕩} # LIMITED to two vector arguments
@@ -96,6 +97,11 @@ Indices←{
}⍟(0<l)𝕩
}
+Transpose←{
+ l←≠𝕩 ⋄ m←1×´c←1 Cell 𝕩
+ (c⥊↕m)(+⟜(m⊸×)⊑(⥊𝕩)˜)⌜↕l
+}⍟(0<=)
+
_under_←{
i←↕l←1×´s←≢𝕩
v←⥊𝕨𝔽○𝔾𝕩
@@ -174,8 +180,6 @@ Depth←IsArray◶0‿{1+0⌈´Depth⌜⥊𝕩}
≢ ↩ ≢ ⊘ (¬Match)
-DropV← {⊑⟜𝕩⌜𝕨+↕𝕨-˜≠𝕩}
-Cell ← DropV⟜≢
Pair ← {⟨𝕩⟩} ⊘ {⟨𝕨,𝕩⟩}
Merge←{
@@ -352,7 +356,6 @@ ReorderAxes←{
𝕨↩𝕨∾𝕨(¬∘∊˜/⊢)↕r
(𝕨⊸⊏Pick𝕩˜)⌜↕⌊´⌜𝕨⊔≢𝕩
}
-Transpose←(=-1˜)⊸ReorderAxes⍟(0<=)
⍉ ← Transpose ⊘ ReorderAxes
# Sorting