subleq
This commit is contained in:
parent
c3a73e60bb
commit
614a837519
@ -31,5 +31,5 @@ RunFractran ← {
|
||||
|
||||
seq ← 200 RunFractran 2‿"17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1"
|
||||
•Out "Generated numbers: "∾•Repr seq
|
||||
•Out "Primes: "∾•Repr (⌈=⌊)∘(2⊸(⋆⁼))⊸/ seq
|
||||
•Out "Primes: "∾•Repr 1↓⌊2⋆⁼(⌈=⌊)∘(2⊸(⋆⁼))⊸/ seq
|
||||
|
||||
|
18
subleq.bqn
Normal file
18
subleq.bqn
Normal file
@ -0,0 +1,18 @@
|
||||
# Subleq interpreter
|
||||
|
||||
_while_ ← {𝔽⍟𝔾∘𝔽_𝕣_𝔾∘𝔽⍟𝔾𝕩}
|
||||
ToNum ← {neg ← '-'=⊑𝕩 ⋄ (¯1⋆neg)×10⊸×⊸+˜´·⌽-⟜'0'neg↓𝕩}
|
||||
|
||||
Subleq ← {
|
||||
𝕊 memory:
|
||||
{
|
||||
𝕊 ip‿mem:
|
||||
{
|
||||
¯1‿b‿·: ⟨ip+3, (@-˜•term.CharB@)⌾(b⊸⊑) mem⟩;
|
||||
a‿¯1‿·: •Out @+a⊑mem, ⟨ip+3, mem⟩;
|
||||
a‿b‿c : d ← b-○(⊑⟜mem)a, ⟨(0<d)⊑⟨c, ip+3⟩, d⌾(b⊸⊑) mem⟩
|
||||
} mem⊏˜ip+↕3
|
||||
} _while_ {𝕊 ip‿mem: ip≥0} 0‿memory
|
||||
}
|
||||
|
||||
Subleq ToNum¨•args
|
Loading…
Reference in New Issue
Block a user