Skip to content

Instantly share code, notes, and snippets.

@olexandr-konovalov
Created January 18, 2016 21:25
Show Gist options
  • Save olexandr-konovalov/38938a74937c882f713d to your computer and use it in GitHub Desktop.
Save olexandr-konovalov/38938a74937c882f713d to your computer and use it in GitHub Desktop.
Quine: a GAP program that prints itself
s := [ "Print(\"s := \", s, \";; \");", "for t in s do Print(t); od;" ];;Print("s := ", s, ";;" );for t in s do Print(t); od;
@olexandr-konovalov
Copy link
Author

Example:

gap> s := [ "Print(\"s := \", s, \";; \");", "for t in s do Print(t); od;" ];;Print("s := ", s, ";;" );for t in s do Print(t); od;
s := [ "Print(\"s := \", s, \";; \");", "for t in s do Print(t); od;" ];;Print("s := ", s, ";; ");for t in s do Print(t); od;

You may also wish to start GAP with -q option, then the output will be aligned with the input so it will be more obvious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment