[comp.lang.prolog] returning self

udi@WISDOM.WEIZMANN.AC.IL (Ehud Shapiro) (01/13/91)

A Prolog program that returns itself (up to renaming):

self((self(_14):-_15)) :- clause(self(_14),_15).



| -? self(X).

X = self((self(_14):-_15)):-clause(self(_14),_15)

gosse@gufal02.let.rug.nl (Gosse Bouma) (01/15/91)

Yet another program printing its own code (no variable renaming or
omission of the '.' this time).


slf :- freeze(X,(name(Y,X),write(Y),write(X),write('.'))),
X=[115,108,102,32,58,45,32,102,114,101,101,122,101,40,88,44,40,110,97,109,101,
40,89,44,88,41,44,119,114,105,116,101,40,89,41,44,119,114,105,116,101,40,
88,41,44,119,114,105,116,101,40,39,46,39,41,41,41,44,10,88,61].


Gosse Bouma, Alfa-informatica, RUG, Groningen	       gosse@let.rug.nl

	All we cry, all we contend for, in this world of toil and blood,
	is beneath the notice of the hacker we call God.   (Th. Pynchon)
--
Gosse Bouma, Alfa-informatica, RUG, Groningen	       gosse@gufalet.let.rug.nl

	All we cry, all we contend for, in this world of toil and blood,
	is beneath the notice of the hacker we call God.   (Th. Pynchon)