Re: [R] Some Programming Humor - Quine

About this list Date view Thread view Subject view Author view Attachment view

From: Barry Rowlingson (B.Rowlingson@lancaster.ac.uk)
Date: Thu 15 May 2003 - 04:50:00 EST


Message-id: <3EC28FD8.6000601@lancaster.ac.uk>


  Well I managed to modify a javascript quine on the quine web page to
create this monster - simply stick it all on one line in a file - I've
split it here for an attempt at clarity:

a=1:10;a[1]='a=1:10;';a[2]='[';a[3]=']';a[4]='\'';a[5]='\\';a[6]='=';a[7]='a';a[8]=';';a[9]='';

a[10]='for(i in 1:10)cat(ifelse(i==1,a[1],a[9])

,a[7],a[2],i,a[3],a[6],a[4],ifelse(i==4||i==5,a[5],a[9]),

a[i],a[4],a[8],ifelse(i==10,a[10],a[9]),sep=a[9])';for(i in 1:10)

cat(ifelse(i==1,a[1],a[9]),a[7],a[2],i,a[3],a[6],a[4],

ifelse(i==4||i==5,a[5],a[9]),a[i],a[4],a[8],ifelse(i==10,a[10],a[9]),sep=a[9])

  This passes the quine script test:

$ R --slave < q2.R >q2o.R
$ diff q2.R q2o.R
  <nothing!>
$

I'm sure if I understood it I could make it better...

Original javascript version by: Geoffrey A Swift (blimey@toke.com)
From: http://www.nyx.net/~gthompso/quine.htm

Baz

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Tue 01 Jul 2003 - 09:11:49 EST