lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I am glad to announce the first release of LuaBrainFuck [1].
This library contains a standard Brainfuck [2] interpreter written for Lua 5.2.
It also features unique Morse and bracket syntaxes for Brainfuck, which better fit Lua environment because the program is not contained in a single string, but (ab)use Lua operators.

As an example, the traditional "Hello World!" example can be written like this in Morse style:

___(_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_.._/_._._/_._/_._/_._/_._/_._/_._/_._/_._._/_._/_._/
_._/_._/_._/_._/_._/_._/_._/_._/_._._/_._/_._/_._/_._._/_._/__._/__._/__._/__._/_.__/_.._._/_._._/
_._/_._/__.__/_._._/_._/__.__/_._/_._/_._/_._/_._/_._/_._/__.__/__.__/_._/_._/_._/__.__/_._._/_._/
_._/__.__/__._/__._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/_._/__.__/_._._/__.__/
_._/_._/_._/__.__/_.__/_.__/_.__/_.__/_.__/_.__/__.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/_.__/__.__/
_._._/_._/__.__/_._._/__.__)

Or like this in the more compact bracket style:

_()()()()()()()()()(){_}(_)()()()()()()()(_)()()()()()()()()()()(_)()()()(_)()[_][_][_][_]{
}[__](_)()()(__)(_)()(__)()()()()()()()(__)(__)()()()(__)(_)()()(__)[_][_]()()()()()()()()(
)()()()()()()(__)(_)(__)()()()(__){}{}{}{}{}{}(__){}{}{}{}{}{}{}{}(__)(_)()(__)(_)(__)(_,_)

Together with a drawing program, LuaBrainFuck can be used to draw beautiful and useful Lua programs in ASCII art, as I had sketched in a recent message [3].
I was in fact unhappy with the fact that the triangle program actually didn't do anything. As Brainfuck is Turing complete, you should now be able to program anything with LuaBrainFuck.

Because of the nature of the LuaBrainFuck implementation, it was easy to add a support for quine. [3] (This was also a surprise for me.)
If you add at the right place a single underscore to the above examples (just to tell the difference), they are turned into quine programs that just output themselves !
And unlike all the quine programs I have seen so far, there is no string containing part of the program source itself: the quine support is just natural, there is no recursion !

Have fun.

[1] https://github.com/prapin/LuaBrainFuck
[2] http://en.wikipedia.org/wiki/Brainfuck
[3] http://lua-users.org/lists/lua-l/2012-11/msg00203.html
[4] http://en.wikipedia.org/wiki/Quine_%28computing%29

--
-- Patrick Rapin
-- coauthor of "Le guide de Lua et ses applications", D-BookeR