[R] Some Programming Humor - Quine
B.Rowlingson at lancaster.ac.uk
Thu May 15 15:43:37 CEST 2003
> so my quine-version seems not to pass this test:
>  FALSE
>  FALSE
> 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.
Thats right. Even if the environment isn't printed, its still there,
and so the quine fails the 'identical' test.
If you can adjust your code to return an object with the same
environment as itself then it will work
> q2 <- quine()
> environment(q2) <- environment(quine)
In fact all you need to do is set the environment to globalenv(). I'm
sure a minor adjustment to your script can fix this!
More information about the R-help