Quine using strings?
Nestor via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jan 15 13:37:53 PST 2017
On Sunday, 15 January 2017 at 19:43:22 UTC, Nestor wrote:
> I was reading some of the examples of writing a quine with D,
> but apparently the language has evolved and they no longer
> compiled unchanged.
>
> So I tried to program one by myself using strings and
> std.stdio, but the result seems long and redundant:
>
> import std.stdio;void main(){string s=`import std.stdio;void
> main(){string
> s=writefln("%s\x60%s\x60;s",s[0..38],s,s[38..$]);}`;writefln("%s\x60%s\x60;%s",s[0..38],s,s[38..$]);}
>
> Any ideas for a shorter version (preferably without using
> pointers)?
Well I just noticed a few problems in the code, I guess quines
are a little complex to write.
More information about the Digitalmars-d-learn
mailing list