aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-07-17 07:28:21 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-07-17 08:06:17 -0400
commit357a9ab4e25a0101121761c503e14ba38d32093c (patch)
tree0cdaedd3eca6f3854a82f86ea50bb231e68ad2dc /spec
parent5c4a7106dc47e2e1849eddf4d87fb0e107461d74 (diff)
Move some files around
Diffstat (limited to 'spec')
-rwxr-xr-xspec/dzref205
1 files changed, 0 insertions, 205 deletions
diff --git a/spec/dzref b/spec/dzref
deleted file mode 100755
index eabf24cf..00000000
--- a/spec/dzref
+++ /dev/null
@@ -1,205 +0,0 @@
-#!/usr/bin/env dbqn
-
-impl ← "
-#⌜
-# LAYER 3: Remove other limits
-# Now all implementations are full but ↕ is monadic only
-
-Int←IsArray◶⟨⌊⊸=,0⟩
-Nat←IsArray◶⟨0⊸≤∧⌊⊸=,0⟩
-
-
-#⌜
-# LAYER 4: Operators
-
-
-Cell ← ↓⟜≢
-
-_ranks ← {⟨2⟩⊘⟨1,0⟩((⊣-1+|)˜⟜≠⊑¨<∘⊢)⥊∘𝔽}
-_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
-
-_onAxes_←{
- F←𝔽
- (𝔾<≡)∘⊣◶{ # One axis
- ! 1≤≠≢𝕩
- 𝕨F𝕩
- }‿{ # Multiple axes
- ! 1≥≠≢𝕨
- ! 𝕨≤○≠≢𝕩
- R←{(⊑𝕨)F(1↓𝕨)⊸R˘𝕩}⍟{0<≠𝕨}
- 𝕨R𝕩
- }
-}
-
-Windows←{
- ! IsArray 𝕩
- ! 1≥≠≢𝕨
- ! 𝕨≤○≠≢𝕩
- ! ∧´Nat¨⥊𝕨
- s←(≠𝕨)↑≢𝕩
- ! ∧´𝕨≤1+s
- 𝕨{(∾⟜(𝕨≠⊸↓≢𝕩)∘≢⥊>)<¨⊸⊏⟜𝕩¨s(¬+⌜○↕⊢)⥊𝕨}⍟(0<≠𝕨)𝕩
-}
-
-Rotate ← ⌽ _onAxes_ 0
-
-↕ ↩ ↕ ⊘ Windows
-⌽ ↩ ⌽ ⊘ Rotate
-
-
-#⌜
-# LAYER 6: Everything else
-
-
-Join←{
- C←(<⟨⟩)⥊⊸∾⌜´⊢ # Cartesian array product
- ! IsArray 𝕩
- s←≢¨𝕩
- d←≠⊑s
- ! ∧´⥊d=≠¨s
- ! d≥≠≢𝕩
- l←(≢𝕩){(𝕩⊑⟜≢a⊑˜(j=𝕩)⊸×)¨↕𝕨}¨j←↕r←≠≢a←𝕩
- ! (r↑¨s)≡C l
- i←C{p←+´¨↑𝕩⋄(↕⊑⌽p)-𝕩/¯1↓p}¨l
- >i<¨⊸⊏¨l/𝕩
-}⍟(0<≠∘⥊)
-
-∾ ↩ Join ⊘ ∾
-
-# Searching
-IndexOf←(1<⌈○(≠≢))◶⊐‿{
- c←1-˜≠≢𝕨
- ! 0≤c
- 𝕨 (0<≠𝕨)◶⟨0⎉c∘⊢,((+´<˘)∧`)≢⎉c⎉c‿∞⟩ 𝕩
-}
-UniqueMask←{
- ! 1≤≠≢𝕩
- u←0↑𝕩
- {(≠u)>⊑u IndexOf 𝕩}◶{u↩u∾𝕩⋄1}‿0˘𝕩
-}
-Find←{
- r←≠s←≢𝕨
- ! r≤≠≢𝕩
- 𝕨 ≡⎉r s ↕⎉r 𝕩
-}
-
-⊐ ← !∘0 ⊘ IndexOf
-∊ ← UniqueMask ⊘ (⊐˜<≠∘⊢)
-⍷ ← ∊⊸/ ⊘ Find
-
-ReorderAxes←{
- 𝕩↩<⍟(0=≡)𝕩
- ! 1≥≠≢𝕨
- 𝕨↩⥊𝕨
- ! 𝕨≤○≠≢𝕩
- ! ∧´Nat¨⥊𝕨
- r←(≠≢𝕩)-+´¬∊𝕨
- ! ∧´𝕨<r
- 𝕨↩𝕨∾𝕨(¬∘∊˜/⊢)↕r
- (𝕨⊸⊏⊑𝕩˜)¨↕⌊´¨𝕨⊔≢𝕩
-}
-Transpose←(≠∘≢-1˜)⊸ReorderAxes⍟(0<≠∘≢)
-⍉ ← Transpose ⊘ ReorderAxes
-
-# Sorting
-Cmp ← ∨○IsArray◶{ # No arrays
- 𝕨(>-<)𝕩 # Assume they're numbers
-}‿{ # At least one array
- e←𝕨-˜○(0∨´0=≢)𝕩
- 𝕨(e=0)◶e‿{
- c←𝕨×∘-○(IsArray+≠∘≢)𝕩
- s←≢𝕨 ⋄ t←≢𝕩 ⋄ r←s⌊○≠t
- l←s{i←+´∧`𝕨=𝕩⋄m←1×´i↑𝕨⋄{c↩×-´𝕩⋄m↩m×⌊´𝕩}∘(⊑¨⟜𝕨‿𝕩)⍟(r⊸>)i⋄m}○(r↑⌽)t
- a←⥊𝕨⋄b←⥊𝕩
- Trav←(=⟜l)◶{Trav∘(1+𝕩)⍟(0⊸=)a Cmp○(𝕩⊸⊑)b}‿c
- Trav 0
- }𝕩
-}
-
-_bins←{
- c←1-˜≠≢𝕨
- ! 0≤c
- LE←𝔽⎉c≤0˜
- ! (0<≠)◶⟨1,∧´·LE´˘2↕<˘⟩𝕨
- 𝕨 (0<≠𝕨)◶⟨0⎉c∘⊢,(+´<˘)LE⎉¯1‿∞⟩ 𝕩
-}
-
-OccurrenceCount ← ⊐˜(⊢-⊏)⍋∘⍋
-ProgressiveIndexOf ← {𝕨⊐○(≍˘⟜OccurrenceCount𝕨⊸⊐)𝕩}
-
-⍋ ↩ ⍋ ⊘ ( Cmp _bins)
-⍒ ↩ ⍒ ⊘ (-∘Cmp _bins)
-⊒ ← OccurrenceCount⊘ ProgressiveIndexOf
-"
-
-X←Raw←{≤4}
-{
- chrs←⟨
- "!∾↕⌽⍉⍋⍒⊐⊒∊⍷"
- ""
- "⚇"
- ⟩
- nc ← ≠¨chrs
- chr ← ∾chrs
- itr ← 0⥊˜≠chr
-
- init ← " "⊸∾¨(/⟜"_"¨nc/0‿1‿1)∾¨(nc/"FMD")∾¨(nc+´⊸↑⥊"AB"∾⌜•a)
- post ← ∾⟜" "¨/⟜"_"¨nc/0‿0‿1
- names ← init∾¨(•UCS 48)∾¨post
-
- Inc ← {
- i←⊑chr⊐𝕩
- n←0 ⋄ itr↩{n↩1+𝕩}⌾(i⊑⊢)itr
- names↩((i⊑init)∾(•UCS 48+n)∾i⊑post)⌾(i⊑⊢)names
- }
-
- # starting built-ins
- inps←⟨"𝕨 ","𝕨,𝕗","𝕨,𝕘"⟩
- ⍎¨names∾¨(nc/("←{⟨"∾∾⟜"⟩ ⋄ ⍎""Using undefined built-in ")¨inps)∾¨∾⟜"""}"¨chr
-
- # built-in assumptions
- Mod ← ⍎{𝔽 ((⊑chr⊐𝕨)⊑names) ∾ " ↩ " ∾ 𝕩}
-
- ⍎"IsArray ← 0≠≡"
- ⍎"Type ← ⟨⟩⥊0⊸⥊"
-
- '!' Mod "{𝕩 ⋄ ≤1}⍟¬"
- Mod⟜⥊¨ "↕∾⌽⊐⍋⍒"
-
-
- # checks if line is a builtin redefinition
- E_isdef ← (3≤≠)◶⟨0,∧´⟨chr," ","←↩"⟩∊˜¨3⊸↑⟩
-
- # removes comments and replaces built-ins with names
- E_proc ← {
- l←≠chr
- q←≠`𝕩∊"""'" ⋄ f←¬∨`q¬⊸∧𝕩='#'
- ∾ (((l×f/q)+chr⊸⊐) (≥⟜l)◶⟨⊑⟜names,⥊∘⊢⟩¨ ⊢) f/𝕩
- }
-
- E_redef ← { # handles [fmd] [←↩]
- tail ← E_proc 3↓𝕩 # must use old def
- Inc ⊑𝕩
- (E_proc 1↑𝕩) ∾ "←" ∾ tail
- }
-
- lf ← •UCS 10
- pre ← E_isdef◶E_proc‿E_redef¨ lf((⊢-˜¬×+`)∘=⊔⊢)impl
- Raw↩⍎
- ExecFile←{Raw ∾ ∾⟜lf¨ E_proc¨ •LNS 𝕩}
- X↩Raw∘E_proc
- ⍎ ∾ ∾⟜lf¨ pre
- ≠◶X‿{ExecFile ⊑𝕩}‿{ExecFile ⊑𝕩 ⋄ X 1⊑𝕩} •args
-}0