lua-users home
lua-l archive

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


Hi !

I was searching the internet about quines (self printing programs), and I couldn't find many examples of Lua quines. In fact, they didn't even work since they seemed to be written for older versions of Lua.

---------
y = [[ print("y = [[" .. y .. "]]\ndostring(y)") ]]
dostring(y)
---------

---------
s=[[s=[[x]]s=string.gsub(s,"x",s,1)print(s)]]s=string.gsub(s,"x",s,1)print(s)
---------

The problem being the nested [[ ]].

I tried to write one myself, and came up with :

---------
s=[[io.write('s=[','[',s,']','];',s)]];io.write('s=[','[',s,']','];',s)
---------

Has anyone written his own yet ?
Cheers,
Noé