[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua quine
- From: Noé Falzon <noe.falzon@...>
- Date: Tue, 13 May 2008 01:56:06 +0200
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é