/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This program bootstraps a Prolog quine. Run it with: $ scryer-prolog -g quine,halt quinebs.pl The emitted output is *almost* a quine. To make it a quine, you need to: 1. replace the three occurrences of \n by \\n in the first two format/1 calls that occur in the emitted definition of prog/1. 2. replace the three newline characters that occur in the emitted format/1 calls of quine/0 by \n I defined the string prog/1 by pasting the entire program source starting after the fact, and replacing (M-x replace-string RET): -) newline (C-o) by \n -) " by \" Written June 1st 2022 by Markus Triska (triska@metalevel.at) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ prog("% This string contains everything starting from here.\n\n\nquine :-\n format(\"% Prolog quine, written June 1st 2022 by Markus Triska (triska@metalevel.at)\n\"),\n format(\"% Usage: $ scryer-prolog -g quine,halt quine.pl\n\n\"),\n prog(Ps),\n writeq(prog(Ps)),\n format([.|Ps]).\n\nformat([]).\nformat([C|Cs]) :-\n write(C),\n format(Cs).\n").% This string contains everything starting from here. quine :- format("% Prolog quine, written June 1st 2022 by Markus Triska (triska@metalevel.at)\n"), format("% Usage: $ scryer-prolog -g quine,halt quine.pl\n\n"), prog(Ps), writeq(prog(Ps)), format([.|Ps]). format([]). format([C|Cs]) :- write(C), format(Cs).