[R] Implementating streams in R

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Feb 3 12:39:05 CET 2004


On Tue, 3 Feb 2004, Gabriel Baud-Bovy wrote:

> Dear all,
> 
> I have an implementation of streams in R. The current implementation of 
> delay() and force() is
> inspired from  the LISP implementation found in Part VI "Languages for AI 
> problem solving" of
> "Artificial Intelligence" by G. Luger.
> 
> I have tested it with the Fibonacci example in the same book (see examples 
> below).  It works
> but I do run into a problem when I try to generate fibonacci series more 
> than 25 elements.
> 
>  > accumulate.into.list(25,fibonacci.stream(0,1))
> Error in cons.stream(fibonacci1 + fibonacci2, 
> fibonacci.stream(fibonacci2,  : evaluation is nested too deeply: infinite 
> recursion?
> 
> Traceback show that the call stack has 101 elements at this point. What is 
> the parameter
> limiting the number of recursive calls to 100?  What is its relation to the 
> "expressions" setting
> in options()?

There isn't one.  The limit is on nesting expressions, as given in 
options().  One call may generate several expressions, though, and your 
calls probably generate 5 each.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list