[R] Quiz {was "Quit asking me .."}
Henrik Bengtsson
hb at maths.lth.se
Wed Sep 17 10:18:06 CEST 2003
First, 42 characters...
Q="no";class(Q)=Q;print.no=function(x)q(Q)
Interestingly, the following works too (41 chars)
Q="";class(Q)=Q;print.=function(x)q("no")
Is it legal though to have empty class names?
And finally, the beautiful one with 28 characters
Q="no";class(Q)=Q;print.no=q
Have nice day!
Henrik Bengtsson
Lund University
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Deepayan Sarkar
> Sent: den 17 september 2003 09:17
> To: Martin Maechler; R-help at stat.math.ethz.ch
> Subject: Re: [R] Quiz {was "Quit asking me .."}
>
>
> On Wednesday 17 September 2003 01:36, Martin Maechler wrote:
>
> > 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?
>
> Barely, 46 removing all spaces:
>
> print.q<-function(x)q("no");Q<-1;class(Q)<-"q"
>
> We can also replace <- by = in recent (and _ in older)
> versions of R to
> decrease this further.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo> /r-help
>
>
More information about the R-help
mailing list