[R] Some Programming Humor - Quine
koller at isis.wu-wien.ac.at
Thu May 15 14:43:00 CEST 2003
At 13:17 15.05.03 +0100, Prof Brian Ripley wrote:
>On Thu, 15 May 2003, Wolfgang Koller wrote:
>> By the way, some questions that arose in this programming exercise:
>> a) is there a simpler way to do the assignment
>> STR <- "\""
>> without using quotes?
>Not simpler, but '"' is probably easier to read.
This version still uses a quote --- the one in the middle. With "simpler" I
meant in comparison with the version I used in quine()-code, which is
admittedly ugly and depends on the source code of paste(), but does not use
quotes (nor double quotes or whatever ' and " are correctly named in English):
STR <- substr(deparse(paste),start=24,stop=24)
Maybe something analogous to letters would be a nice additional feature
in R? I have needed something like that on several occasions before.
>> b) what does this cryptic <environment: 034768AC> (or similar) mean that
>> does appear after the return value of quine() but not after the result of
>All R functions have environments. This is not printed when the function
>is printed if and only if the environment is the user's workspace.
>The number is a Hex address of the environment, and you will see it when
>functions are defined or generated inside functions.
>> c) is there a better way to check if two functions are identical than the
>> way suggested above?
so my quine-version seems not to pass this test:
has this to do with the environment somehow being part of the function? I
dont quite understand, since quine(), quine()(), quine()()() all look quite
identical to me, save the information about the environment that is added
after the return value.
Wolfgang Koller, wolfgang.koller at wu-wien.ac.at
Forschungsinstitut für Europafragen
Althanstraße 39-45, 1090 Vienna, Austria
Tel: ++43/1/31336/4147 Fax: ++43/1/31336/758
More information about the R-help