Re: [R] odd feature

From: Martin Maechler <>
Date: Tue 23 May 2006 - 00:42:44 EST

>>>>> "TL" == Thomas Lumley <> >>>>> on Mon, 22 May 2006 07:09:09 -0700 (PDT) writes:

    TL> On Mon, 22 May 2006, Gabor Grothendieck wrote:
>> Due to lazy evaluation, I don't think a and b are fully evaluated:

    >>> ifelse(1, a <- 1, b <- 2)

>> [1] 1
    >>> a

>> [1] 1

    >>> b
>> Error: object "b" not found
    TL> yes. If you look at the code for ifelse() it evaluates
    TL> the second argument if any test values are TRUE and the
    TL> third argument if any test values are FALSE, so in the
    TL> scalar case it does not evaluate both arguments.

And (Gabor), if you recall what I said earlier, it's pretty clear that I would not even *consider* using ifelse() in the scalar case. So my original statement was about the case ifelse() is designed for: The non-trivial vector case, and there my statement of "fully evaluated" does apply.

Martin mailing list PLEASE do read the posting guide! Received on Tue May 23 01:00:14 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 23 May 2006 - 04:10:21 EST.

Mailing list information is available at Please read the posting guide before posting to the list.