Lunge is a Befunge-93 programming language interpreter written in Lua.
- I am bored at midnight
- I hadn't written anything in Lua for a while
- I couldn't find Befunge interpreter written in Lua
Import Befunge module with require 'befunge', create a new interpreter
instance with Befunge.new('some code') and run it with run method.
Notice how [[multiline strings]] are used - Lua my beloved got us covered
here too. When run stops, it returns interpreter's status.
You also may advance algorithm execution step by step with advance method.
See examples folder for more algorithms. You can find them (and more) on esoteric programming languages wiki - Esolang.
local Befunge = require 'befunge'
-- "Hello world"
local hw = Befunge.new [[
> v
v"Hello World!"<
>:v
^,_@
]]
local hwstatus = hw:run()
print()
-- DNA-code
local dna = Befunge.new [[
7^DN>vA
v_#v? v
7^<""""
3 ACGT
90!""""
4*:>>>v
+8^-1,<
> ,+,@)
]]
local dnastatus = dna:run()
-- Quine
local quine = Befunge.new [[
01->1# +# :# 0# g# ,# :# 5# 8# *# 4# +# -# _@
]]
local quinestatus = quine:run()
print()
for _, s in ipairs{hwstatus, dnastatus, quinestatus} do
assert(s == 'finished')
end