Skip to content
Back to formatted view

Raw Message

Message-ID: <CAAmySGMbBb9tEKbUVgeBw+wUD610ZqDKB30Si=tL9LM4MD8vnQ@mail.gmail.com>
Date: 2012-05-15T05:25:57Z
From: R. Michael Weylandt
Subject: Inf and lazy evaluation
In-Reply-To: <CA+nJqYOZH-0tPMQB9H6By14o3y7Z9BrdW5hgpkG28F=+7_4-zQ@mail.gmail.com>

The only place I know lazy evaluation really is visible and widely
used is in the passing of function arguments. It's what allows magic
like

zz <- 1:5
plot(zz)

to know your variable was called "zz." It can also show up in some
places through the promise mechanism, but you have to do a little bit
of work to see them:

zz <- lapply(1:3, function(i) function(x) x^i)

zz[[2]](2)

Without lazy evaluation this would have been 4. Sometimes this winds
up hurting folks -- I'm not sure if it has a "good reason" to be there
or if its a consequence of lazy mechanisms elsewhere (which improve
overall performance)

But I don't believe R allows lazy constructors in any context.

Best,
Michael

On Mon, May 14, 2012 at 4:29 PM, J Toll <jctoll at gmail.com> wrote:
> Thank you all for the replies.
>
> On Mon, May 14, 2012 at 2:45 PM, R. Michael Weylandt
> <michael.weylandt at gmail.com> wrote:
>> R is lazy, but not quite that lazy ;-)
>
> Oh, what is this world coming to when you can't count on laziness to
> be lazy. ;) ?I should probably stop reading about Haskell and their
> lazy way of doing things.
>
> As a relatively naive observation, in R, it seems like argument
> recycling kind of breaks the power of lazy evaluation.
>
> Thanks for the suggestion of list.files()
>
>
> James