[R] Some Programming Humor - Quine

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Wed May 14 20:50:00 CEST 2003

  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[10]='for(i in 1:10)cat(ifelse(i==1,a[1],a[9])


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



  This passes the quine script test:

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

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

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


More information about the R-help mailing list