diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-08-08 15:59:34 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-08-08 15:59:34 -0400 |
| commit | 37a440133d6d1c2118682fd163d8f616f8d712b6 (patch) | |
| tree | b29070307d4a0e200e1d2c9885b8a1aa81019ef3 /src | |
| parent | a391024132bb9dbb1f89da1243d5631fa29d5593 (diff) | |
Add Group components as basic functionality
Diffstat (limited to 'src')
| -rwxr-xr-x | src/pr.bqn | 2 | ||||
| -rw-r--r-- | src/r.bqn | 22 |
2 files changed, 18 insertions, 6 deletions
@@ -24,7 +24,7 @@ Inc ← { } # Required functionality passed in as an argument -pnam ← ⟨"IsArray", "Type", "Log"⟩∾names⊏˜chr⊐"!+-×÷⋆⌊=≤≢⥊⊑↕⌜`" +pnam ← ⟨"IsArray","Type","Log","GroupLen","GroupOrd"⟩∾names⊏˜chr⊐"!+-×÷⋆⌊=≤≢⥊⊑↕⌜`" E_isdef ← (3≤≠)◶⟨0,∧´⟨chr," ","←↩"⟩∊˜¨3⊸↑⟩ @@ -299,17 +299,29 @@ Join←(1≠=)◶⟨∨´1≠=⌜,1⟩◶{ >i<⌜⊸⊏¨l/𝕩 }⍟(0<≠∘⥊) -Group←{ +_group←{ + !1==𝕩⋄!∧´Int⌜𝕩⋄!∧´¯1≤𝕩 + d←(l←GroupLen𝕩)GroupOrd𝕩 + i←0⋄(𝔽{𝕩⋄(i↩i+1)⊢i⊑d}⌜∘↕)⌜l +} +GroupInds←{ + ! IsArray 𝕩 + G←⊢_group + (1<≡)◶G‿((<<⟨⟩)⥊⊸∾⌜⌜´G⌜)𝕩 +} +GroupGen←{ ! IsArray 𝕩 - Chk←{!1==𝕩⋄!∧´Int⌜𝕩⋄!∧´¯1≤𝕩⋄≠𝕩} - l←(1<≡)◶Chk‿{!1==𝕩⋄Chk⌜𝕩}𝕨 + m←1<≡𝕨 + l←m◶≠‿{!1==𝕩⋄≠⌜𝕩}𝕨 ! l≤○≠≢𝕩 ! ∧´l=l≠⊸↑≢𝕩 - (𝕨⊸=/𝕩˜)⌜↕1+¯1⌈´⚇1𝕨 + 𝕨m◶(⊏⟜𝕩_group⊣)‿{ + ⊏⟜(𝕩⥊˜⟨×´l⟩∾(≠l)Cell𝕩)⌜ +⌜⌜´ (⌽×`⟨1⟩∾⌽1↓l) × ⊢_group⌜𝕨 + }𝕩 } ∾ ↩ Join ⊘ JoinTo -⊔ ← Group⟜(↕≠⚇1) ⊘ Group +⊔ ← GroupInds ⊘ GroupGen Pick1←{ ! 1==𝕨 |
