[R] Quiz {was "Quit asking me .."}

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Sep 17 09:16:00 CEST 2003


Martin Maechler wrote:

>>>>>>"Spencer" == Spencer Graves <spencer.graves at pdf.com>
>>>>>>    on Tue, 16 Sep 2003 19:54:22 -0700 writes:
> 
> 
>     Spencer> Consider
>     Spencer>  Q <- function(x)q("no")
> 
>     Spencer> With R 1.7.1 under Windows, "Q()" caused R to close
>     Spencer> without asking for confirmation.  This does not
>     Spencer> solve the whole problem, but it might provide a
>     Spencer> piece of the puzzle.
> 
> Apropos, this reminds me of the old quiz (from the S-plus times):
> 
> How can you write (quite short!) R code such that
> typing
> 	"Q"   
> 
> -- without any  "()" -- will quit R (without asking about saving).
> 
> [But you shouldn't really keep that code active in your standard R session
>  because it would be too easy to accidentally shut down R !]
> 
> For the advanced ones: 
> My shortest solution uses 51 characters of R code, can you beat that?
> 

Less than 51 is not that hard, Martin: 46 (counting line breaks as 
characters):

Q<-1
class(Q)<-"Q"
print.Q<-function(x)q("no")

Uwe




More information about the R-help mailing list