Path: Computer > Computer > Miscellanea > Selfish
Selfish
The selfish is a not very well-known fish. Its main habitat is the South Sea bubble where there are no natural predators left (they all emigrated to London between 1710 and 1720 and never looked back). Anyway, the species looks pretty boring but it has a few interesting properties.
I have caught one selfish during a recent expedition to the South Sea and subjected the poor thing to a few experiments, before throwing it on the grill (they are very tasty, especially with a good bottle of Rheingau Riesling). Here is the source for the selfish's DNA which has the amazing side effect of printing itself if executed in suitable South Sea bubble software (otherwise known as Perl):
sub fish() { print "sub fish() {\n"; # ...or whatever else you want } sub sel { fish(); printf $dna,39,$dna,39; } # main $dna=' print "sub fish() {\n"; # ...or whatever else you want } sub sel { fish(); printf $dna,39,$dna,39; } # main $dna=%c%s%c; sel();'; sel();
Another interesting feature of this DNA is that by editing it you can produce many new varieties of selfish. Just change the string after the '#main' line, execute the script and put its output into selfish2.pl — and hey presto, you have a new selfish… which then will be the starting point for selfish #3. And so on, the possibilities are almost endless… (I did mention that the species is a bit boring?)
BTW, the Idle version (also runs with Lua) of the selfish DNA looks like that:
-- The Self-Creating Demiurge local function fish() print('-- The Self-Creating Demiurge\n\nlocal function fish()') -- ...or whatever else you want end local function sel(dna) fish() io.write(string.format(dna,91,91,dna,93,93)) end -- main local dna=[[ print('-- The Self-Creating Demiurge\n\nlocal function fish()') -- ...or whatever else you want end local function sel(dna) fish() io.write(string.format(dna,91,91,dna,93,93)) end -- main local dna=%c%c%s%c%c sel(dna) ]] sel(dna)
Happy selfishing!
$updated from: Selfish.htxt Thu 27 Apr 2017 10:06:49 thomasl (By Thomas Lauer)$