From b3ecbb5695a5a0a0637c924da0022abca940ffee Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 21 Jul 2020 19:13:22 -0400 Subject: Add Rank function as monadic = --- dzref | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'dzref') diff --git a/dzref b/dzref index eabf24cf..4ce64b25 100755 --- a/dzref +++ b/dzref @@ -33,10 +33,10 @@ _depthOp_←{ _onAxes_←{ F←𝔽 (𝔾<≡)∘⊣◶{ # One axis - ! 1≤≠≢𝕩 + ! 1≤=𝕩 𝕨F𝕩 }‿{ # Multiple axes - ! 1≥≠≢𝕨 + ! 1≥=𝕨 ! 𝕨≤○≠≢𝕩 R←{(⊑𝕨)F(1↓𝕨)⊸R˘𝕩}⍟{0<≠𝕨} 𝕨R𝕩 @@ -45,7 +45,7 @@ _onAxes_←{ Windows←{ ! IsArray 𝕩 - ! 1≥≠≢𝕨 + ! 1≥=𝕨 ! 𝕨≤○≠≢𝕩 ! ∧´Nat¨⥊𝕨 s←(≠𝕨)↑≢𝕩 @@ -69,8 +69,8 @@ Join←{ s←≢¨𝕩 d←≠⊑s ! ∧´⥊d=≠¨s - ! d≥≠≢𝕩 - l←(≢𝕩){(𝕩⊑⟜≢a⊑˜(j=𝕩)⊸×)¨↕𝕨}¨j←↕r←≠≢a←𝕩 + ! d≥=𝕩 + l←(≢𝕩){(𝕩⊑⟜≢a⊑˜(j=𝕩)⊸×)¨↕𝕨}¨j←↕r←=a←𝕩 ! (r↑¨s)≡C l i←C{p←+´¨↑𝕩⋄(↕⊑⌽p)-𝕩/¯1↓p}¨l >i<¨⊸⊏¨l/𝕩 @@ -79,20 +79,20 @@ Join←{ ∾ ↩ Join ⊘ ∾ # Searching -IndexOf←(1<⌈○(≠≢))◶⊐‿{ - c←1-˜≠≢𝕨 +IndexOf←(1<⌈○=)◶⊐‿{ + c←1-˜=𝕨 ! 0≤c 𝕨 (0<≠𝕨)◶⟨0⎉c∘⊢,((+´<˘)∧`)≢⎉c⎉c‿∞⟩ 𝕩 } UniqueMask←{ - ! 1≤≠≢𝕩 + ! 1≤=𝕩 u←0↑𝕩 {(≠u)>⊑u IndexOf 𝕩}◶{u↩u∾𝕩⋄1}‿0˘𝕩 } Find←{ - r←≠s←≢𝕨 - ! r≤≠≢𝕩 - 𝕨 ≡⎉r s ↕⎉r 𝕩 + r←=𝕨 + ! r≤=𝕩 + 𝕨 ≡⎉r (≢𝕨) ↕⎉r 𝕩 } ⊐ ← !∘0 ⊘ IndexOf @@ -101,16 +101,16 @@ Find←{ ReorderAxes←{ 𝕩↩<⍟(0=≡)𝕩 - ! 1≥≠≢𝕨 + ! 1≥=𝕨 𝕨↩⥊𝕨 ! 𝕨≤○≠≢𝕩 ! ∧´Nat¨⥊𝕨 - r←(≠≢𝕩)-+´¬∊𝕨 + r←(=𝕩)-+´¬∊𝕨 ! ∧´𝕨)i⋄m}○(r↑⌽)t a←⥊𝕨⋄b←⥊𝕩 Trav←(=⟜l)◶{Trav∘(1+𝕩)⍟(0⊸=)a Cmp○(𝕩⊸⊑)b}‿c @@ -129,7 +129,7 @@ Cmp ← ∨○IsArray◶{ # No arrays } _bins←{ - c←1-˜≠≢𝕨 + c←1-˜=𝕨 ! 0≤c LE←𝔽⎉c≤0˜ ! (0<≠)◶⟨1,∧´·LE´˘2↕<˘⟩𝕨 @@ -147,7 +147,7 @@ ProgressiveIndexOf ← {𝕨⊐○(≍˘⟜OccurrenceCount𝕨⊸⊐)𝕩} X←Raw←{≤4} { chrs←⟨ - "!∾↕⌽⍉⍋⍒⊐⊒∊⍷" + "!=∾↕⌽⍉⍋⍒⊐⊒∊⍷" "" "⚇" ⟩ @@ -176,6 +176,7 @@ X←Raw←{≤4} ⍎"Type ← ⟨⟩⥊0⊸⥊" '!' Mod "{𝕩 ⋄ ≤1}⍟¬" + '=' Mod "≠∘≢ ⊘ =" Mod⟜⥊¨ "↕∾⌽⊐⍋⍒" -- cgit v1.2.3