Re: Another quine
- Posted by Pete Eberlein <xseal at HARBORSIDE.COM> Aug 22, 2000
- 489 views
Hi Davi, This is sort of a recursive quine... -- constant x="constant %s =", y="puts(1, %s)", z="length(%s)" printf(1, sprintf("%s\"%s\\n\",\ny=\"%s\\n? x\\n%s\",\n"& "z=sprintf(y,{%s,%s+1,%s+%s})\n%s\n?x&z\n%s", {x,x,y,y,z,z,z,z,y,y}), "xx"&{"x[1..%d]","x[%d..%d]"}&"xxxyxz") -- save this to a file called "one.ex" ex one > two.ex ex two > three.ex ex three The actual quine is three.ex. Regards, -- Pete On Mon, 21 Aug 2000 23:05:44 -0300, Davi Tassinari de Figueiredo <davitf at USA.NET> wrote: >Hi again, > >I know most of you are not interested at all in this, but I thought >someone might >like it: I've just made another program that prints itself on the >screen. Although >it is somewhat larger than my previous one (removing the comment and >making some >minor modifications, that one becomes 453 bytes long, while this one is >545 bytes >long), I think this one uses a more interesting method (?). > >-- begin code > >atom k,b constant q='"',s='\\',n='\n',r=q&s,z={s&q,s&s},a={ >"atom k,b constant q='\"',s='\\\\',n='\\n',r=q&s,z={s&q,s&s},a={", >"}puts(1,a[1]&n&q)for o=1to length(a[1])do b=a[1][o]k=find(b,r)if k", >"then puts(1,z[k])else puts(1,b)end if end for for o=2to 4do", >"puts(1,q&','&n&q&a[o])end for puts(1,q)for o=2to 4do puts(1,n&a[o])end >for" >}puts(1,a[1]&n&q)for o=1to length(a[1])do b=a[1][o]k=find(b,r)if k >then puts(1,z[k])else puts(1,b)end if end for for o=2to 4do >puts(1,q&','&n&q&a[o])end for puts(1,q)for o=2to 4do puts(1,n&a[o])end >for > >-- end code > >Regards, >Davi Figueiredo >davitf at usa.net