1. Quine - a program that replicates itself

------=_NextPart_000_0009_01C0091B.3F2489A0
        charset="iso-8859-1"

Here's an interesting brain teaser - writing a quine in Euphoria. For those
of you that don't know what a quine is: A Quine is a program that replicates
itself exactly.  A program that copies it's own code from disk does not
count.
I have attached my first quine if you are interested. This program takes
advantage of Euphoria's native atom/sequence structure, and methods of
displaying sequences. It does not write to disk, just to the monitor.

I would be interested in seeing different quines in Euphoria. Euphoria's
handling of sequences lends itself to many potential variations of quine.

Kind Regards,
Aidan.

------=_NextPart_000_0009_01C0091B.3F2489A0
        name="Quine.ex"
Content-Transfer-Encoding: quoted-printable

new topic     » topic index » view message » categorize

2. Re: Quine - a program that replicates itself

Been there, done that :)


Pete

On Fri, 18 Aug 2000 13:50:19 +1000, Aidan Bindoff <abindoff at ONE.NET.AU>
wrote:

>Here's an interesting brain teaser - writing a quine in Euphoria. For those
>of you that don't know what a quine is: A Quine is a program that
replicates
>itself exactly.  A program that copies it's own code from disk does not
>count.
>I have attached my first quine if you are interested. This program takes
>advantage of Euphoria's native atom/sequence structure, and methods of
>displaying sequences. It does not write to disk, just to the monitor.
>
>I would be interested in seeing different quines in Euphoria. Euphoria's
>handling of sequences lends itself to many potential variations of quine.
>
>Kind Regards,
>Aidan.
>

new topic     » goto parent     » topic index » view message » categorize

3. Re: Quine - a program that replicates itself

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 message » categorize

4. Re: Quine - a program that replicates itself

> 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",
> l2="%sprintf(1,l1,{{},msg&n,s&s,s,s&q,q&t&q,n})%s"
> &"puts(1,%smsg=%s&q&msg&q&','&n)%s"
> &"printf(1,%sl1=%s&l1,{q&t,t,t,t,t,t,t&q&','&n})%s"
> &"printf(1,%sl2=%s&l2,{q&t,x,t,t,x,t,t,x,t,t,x,t&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="&l2,{q&t,x,t,t,x,t,t,x,t,t,x,t&q&n})
> printf(1,l2,{{},n,q,q,n,q,q,n,q,q,n,n})

> I hope you like it ;)
>
> Regards,
> Davi Figueiredo
> davitf at usa.net
>

Davi,  very nice. More elegant? "This is a self-replicating program" is
pretty brassy! blink

Kind Regards,
Aidan.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Quine - a program that replicates itself

So it prints its code out. Whoop dee doo

new topic     » goto parent     » topic index » view message » categorize

6. Re: Quine - a program that replicates itself

>So it prints its code out. Whoop dee doo
>

So you run around a post-apocolyptic city with an assortment of guns.
Whoop dee doo

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu