#!/usr/bin/env dbqn impl ← " #⌜ # LAYER 4: Operators ValidateRanks←{ ! 1≥=𝕩 𝕩↩⥊𝕩 ! (1⊸≤∧≤⟜3)≠𝕩 ! ∧´⌊⊸=⌜𝕩 𝕩 } _ranks ← {⟨2⟩⊘⟨1,0⟩ ((⊣-1+|)˜⟜≠⊑¨<∘⊢) ValidateRanks∘𝔽} _depthOp_←{ neg←0>n←𝕨𝔾_ranks𝕩 ⋄ F←𝔽 _d←{ R←(𝕗+neg)_d 𝕨(2⥊(neg∧𝕗≥0)∨(0⌈𝕗)≥≍○<○≡)◶(⟨R¨⋄R⟜𝕩¨∘⊣⟩≍⟨(𝕨R⊢)¨∘⊢⋄F⟩)𝕩 } 𝕨 n _d 𝕩 } ⚇ ← _depthOp_ #⌜ # LAYER 5: Structural functions Windows←{ Nat←(1=•Type)◶⟨0,0⊸≤∧⌊⊸=⟩ ! 0=•Type 𝕩 ! 1≥=𝕨 ! 𝕨≤○≠≢𝕩 ! ∧´Nat¨⥊𝕨 s←(≠𝕨)↑≢𝕩 ! ∧´𝕨≤1+s 𝕨{(∾⟜(𝕨≠⊸↓≢𝕩)∘≢⥊>)<¨⊸⊏⟜𝕩¨s(¬+⌜○↕⊢)⥊𝕨}⍟(0<≠𝕨)𝕩 } ↕ ↩ ↕ ⊘ Windows #⌜ # LAYER 6: Everything else # Searching IndexOf←(1<⌈○=)◶⊐‿{ c←1-˜=𝕨 ! 0≤c 𝕨 (0<≠𝕨)◶⟨0⎉c∘⊢,(+˝∧`)≢⎉c⎉c‿∞⟩ 𝕩 } MarkFirst←{ ! 1≤=𝕩 u←0↑𝕩 {(≠u)>⊑u IndexOf 𝕩}◶{u↩u∾𝕩⋄1}‿0˘𝕩 } Find←{ r←=𝕨 ! r≤=𝕩 𝕨 ≡⎉r ((1+r-⊸↑≢𝕩)⌊≢𝕨)⊸↕⎉r 𝕩 } ⊐ ↩ ⊐ ⊘ IndexOf ∊ ← MarkFirst ⊘ (⊐˜<≠∘⊢) ⍷ ← ∊⊸/ ⊘ Find OccurrenceCount ← ⊐˜(⊢-⊏)⍋∘⍋ ProgressiveIndexOf ← {𝕨⊐○(≍˘⟜OccurrenceCount𝕨⊸⊐)𝕩} ⊒ ← OccurrenceCount⊘ ProgressiveIndexOf " raw ← {•Eval} X ← {F:≤4} _withRef ← ˙ {v: chrs←⟨ "↕⊐⊒∊⍷" "" "⚇" ⟩ # built-in assumptions GetRepls ← { c‿n ← 𝕩 ⋄ k←"↕⊐" ⟨c,(⥊¨k)⌾(((⊑¨c)⊐k)⊸⊏)n⟩ ∾⟜<¨ ⟨"•Eval","(•Eval _withRef)"⟩ } ⟨E_proc⟩ ← chrs‿GetRepls •Import "src/pp.bqn" E_nodef ← 0⊸E_proc ExecFile←{ ((•path⊸∾⌾⊑(2∾˜∧`⌾⌽'/'≠𝕩)⊔𝕩)∾⟨𝕨⟩) Raw E_nodef •FChars 𝕩 } _withRef ↩ {𝔽∘E_nodef⊘(𝔽⟜E_nodef)} X↩Raw _withRef Raw E_proc impl (1⊸↓ ExecFile ⊑) •args }