aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-09-05 12:46:14 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-09-05 12:46:14 -0400
commit053d9b3038977db5cbf1921a144366ebaf774cfe (patch)
tree480971854144f55de9228b11ac1cdf6aad3bb51e
parentf4976087be468414efcf3ce144d8e1249575e1cb (diff)
Extend Group and Group Indices reference implementations
-rw-r--r--spec/reference.bqn17
1 files changed, 12 insertions, 5 deletions
diff --git a/spec/reference.bqn b/spec/reference.bqn
index e0f0bc48..e76ab0c0 100644
--- a/spec/reference.bqn
+++ b/spec/reference.bqn
@@ -359,11 +359,18 @@ Join←{
Group←{
! IsArray 𝕩
- Chk←{!1==𝕩⋄!∧´Int¨𝕩⋄!∧´¯1≤𝕩⋄≠𝕩}
- l←(1<≡)◶Chk‿{!1==𝕩⋄Chk¨𝕩}𝕨
- ! l≤○≠≢𝕩
- ! ∧´l=l≠⊸↑≢𝕩
- (𝕨⊸=/𝕩˜)¨↕1+¯1⌈´⚇1𝕨
+ 𝕨↩Pair∘ToArray⍟(2>≡)𝕨
+ ! 1==𝕨
+ {!∧´Int¨𝕩⋄!∧´¯1≤𝕩}∘⥊¨𝕨
+ n←+´=¨𝕨
+ ! n≤=𝕩
+ ! (∾≢⌜𝕨)≡n↑≢𝕩
+ 𝕨↩⥊¨𝕨 ⋄ 𝕩↩((≠¨𝕨)∾n↓≢𝕩)⥊𝕩
+ (𝕨⊸=/𝕩˜)¨↕1+¯1⌈´¨𝕨
+}
+GroupInds←{
+ ! 1==𝕩
+ 𝕩 ⊔ ↕ (1<≡)◶≠‿(∾≢¨) 𝕩
}
# Searching