Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site mcvax.UUCP Path: utzoo!linus!philabs!mcvax!steven From: steven@mcvax.UUCP (Steven Pemberton) Newsgroups: net.lang.c Subject: Re: palindromic C programs Message-ID: <5953@mcvax.UUCP> Date: Mon, 3-Sep-84 11:45:31 EDT Article-I.D.: mcvax.5953 Posted: Mon Sep 3 11:45:31 1984 Date-Received: Thu, 13-Sep-84 04:59:32 EDT References: <155@ihnet.UUCP> <276@metheus.UUCP> Organization: CWI, Amsterdam Lines: 21 > Are there any programs out there that when program > 'foo' is executed it creates source for program 'bar' and vice- > versa? The result would be a bistable self generating program. > And if bistable is possible, how about tristable, etc.? In issue 47 of the Algol Bulletin, Chris Thomson of the Chion Corporation presented, apart from a self-replicating Algol 68 program, ones that replicated after 2 cycles (thus a=>b=>a), 3 cycles, 9 cycles, and then finally a program that replicates itself after a random-length cycle of expected length 1000! For those of you interested, here is that last one: (.INT s:= 0,e:=123;.STRING a="(.INT s:= 0,e:=123; .STRING a="";s:=(s*9+7)%*1000000;print(2*(a[:9]+whole( (s%1000=e|0|s),5)+a[15:33]+2*a[33:]))";s:=(s*9+7)%*100000; print(2*(a[:9]+whole((s%100=e|0|s),-5)+a[15:33])+2*a[33:])) Subscripts can be used to get a substring of a string, eg a[15:33]. a[33:] means from 33 to the end. % is integer division, %* is mod, (b|v1|v2) is the same as C's e?v1:v2 and whole converts a value to a string.