[R] Some Programming Humor

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Wed May 14 11:37:32 CEST 2003

Douglas Bates wrote:
> Douglas Bates <bates at cs.wisc.edu> writes:
>>I checked and R is one of the 515 languages mentioned in the enclosed.

  Very nice. But where's the S version? :)

  On a similar note, has anyone written a quine in R? Its defined here:


as a program that reproduces itself on an output device without 
inputting its source. There are examples in many languages, but I dont 
see R or S.

For R I think that would mean that:

   R --slave <quine.R >quined.R

  produces quined.R as an identical file to quine.R

  You could probably also have an R quine on a functional level, such that:

  quined <- quine()

  returns 'quined' as an identical function to 'quine'.

The rule about not inputting the source rules out the use of 'get' in R, 
as in:

 > quine <- function(){get("quine")}

  Which is a quine:

 > quine()
 > quine

  Anyone up for a challenge?


More information about the R-help mailing list