This commit is contained in:
razetime 2022-03-18 11:43:02 +05:30
parent 00ef532602
commit c3a73e60bb
1 changed files with 35 additions and 0 deletions

35
fractran.bqn Normal file
View File

@ -0,0 +1,35 @@
# Fractran interpreter
# Helpers
_while_ {𝔽𝔾𝔽_𝕣_𝔾𝔽𝔾𝕩}
ToInt 10×+˜´·-'0'
ToFrac {
i /'/'=𝕩
ToInt¨i(1+)𝕩
}
Split ((¬-˜×·+`»>))
Fractran {
𝕊 nnumden:
ind /0=den|num×n
(n×indnum)÷indden num den
}
RunFractran {
steps 𝕊 inpprg:
numden <˘>ToFrac¨' 'Split prg
step 1
list inp
{
step + 1
out Fractran 𝕩
list out
out
} _while_ {𝕊 nnumden: (step<steps) ´0=den|num} inpnumden
list
}
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