3 ms·
Fractran Interpreter
- siraben 1y agoFractran is a cool esolang that looks impossible to write any programs in at first until you systematically trace through some examples. A while ago I wrote an assembler in Haskell with an optimizer so you can write programs in assembly-style. λ> pretty (sumTo 10) c += 0 n += 10 while n >= 0 { c += n n -= 1 } λ> runAssembler (sumTo 10) -- Program length: 31 Right [847425747 % 2,13 % 3,19 % 13,11 % 3,11 % 29,31 % 11,41 % 31,23 % 11,23 % 47,2279 % 23,59 % 301,59 % 41,67 % 413,329 % 67,61 % 59,73 % 61,83 % 73,71 % 61,71 % 97,445 % 71,707 % 89,103 % 5353,103 % 83,109 % 5459,5141 % 109,107 % 103,113 % 749,113 % 19,131 % 113,29 % 131,127 % 113] λ> runAsm (sumTo 10) [(Prime 97,55),(Prime 107,1)]
- __s 1y agoYou should share link: https://github.com/siraben/hasktran https://github.com/siraben/hasktran
- shawn_w 1y agoJust whipped up an interpreter in Racket for this, returning values lazily in a stream. Figuring out how to get actual prime numbers out of the primegame program was the hard part.