Skip to content
Back to formatted view

Raw Message

Message-ID: <7e5df3fe0911271236u68330ce0y5dc19d7cee867306@mail.gmail.com>
Date: 2009-11-27T20:36:33Z
From: Alexander Søndergaard
Subject: Iteration idioms & laziness

Hi all,

I'm new to R. Having a functional background, I was wondering what's
the idiomatic way to iterate. It seems that for loops are the default
given there's no tail-call optimization.

I'm curious to know whether there is a way to transform the following
toy snippet into something that doesn't eat up gigabytes of memory
(like it's for loop counterpart) using laziness:

Reduce('+', seq(1,1e6))

Thanks!

Best regards,
A.S.