Re: Quine - a program that replicates itself

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hi,

I tried to create a self-replicating program some weeks ago. I decided
not to use numbers to represent characters (such as writing '34' instead
of a quote); I thought it was not a very "elegant" approach.

Here is the program I wrote:

-- begin code

-- This is a self-replicating program
constant s='\\',n='\n',q='\"',t="%s",x=t&q&n&'&'&q,
msg="This is a self-replicating program",
l1="%s-- %sconstant s='%s',n='%sn',q='%s',t=%s,x=t&q&n&'&'&q,%s",
&"puts(1,%smsg=%s&q&msg&q&','&n)%s"
&"printf(1,l2,{{},n,q,q,n,q,q,n,q,q,n,n})%s"
printf(1,l1,{{},msg&n,s&s,s,s&q,q&t&q,n})
puts(1,"msg="&q&msg&q&','&n)
printf(1,"l1="&l1,{q&t,t,t,t,t,t,t&q&','&n})
printf(1,l2,{{},n,q,q,n,q,q,n,q,q,n,n})

-- end code

I hope you like it ;)

Regards,
Davi Figueiredo
davitf at usa.net

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu