Re: Fibonacci: returning a selection of the series

2010-09-02 Thread Baba
On Aug 29, 7:18 pm, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: In general, if you have a program that produces something just to remove/ignore it five lines later, you have a problem. In your case: 1) are you sure you need to append to list(*) at every iteration? When do you *really*

Fibonacci: returning a selection of the series

2010-08-29 Thread Baba
level: beginner i would like to return a selection of the Fibonacci series. example: start = 5 ; end = 55 the function should then return [5, 8, 13, 21, 34, 55] it seems that this is best resolved using an iterative approach to generate the series. In another post

Re: Fibonacci: returning a selection of the series

2010-08-29 Thread Alain Ketterlin
Baba raoul...@gmail.com writes: i would like to return a selection of the Fibonacci series. example: start = 5 ; end = 55 the function should then return [5, 8, 13, 21, 34, 55] [...] my questios: - would you agree that recursive is not ideal for generating a list? (in this particular case

Re: Fibonacci: returning a selection of the series

2010-08-29 Thread News123
On 08/29/2010 07:36 PM, Baba wrote: level: beginner i would like to return a selection of the Fibonacci series. example: start = 5 ; end = 55 the function should then return [5, 8, 13, 21, 34, 55] it seems that this is best resolved using an iterative approach to generate the series.

Re: Fibonacci: returning a selection of the series

2010-08-29 Thread geremy condra
On Sun, Aug 29, 2010 at 10:36 AM, Baba raoul...@gmail.com wrote: level: beginner i would like to return a selection of the Fibonacci series. example: start = 5 ; end  = 55 the function should then return [5, 8, 13, 21, 34, 55] it seems that this is best resolved using an iterative approach

Re: Fibonacci: returning a selection of the series

2010-08-29 Thread Arnaud Delobelle
Baba raoul...@gmail.com writes: my questios: - would you agree that recursive is not ideal for generating a list? (in this particular case and in general) In Python that is probably correct in the vast majority of cases for two reasons: * lists in Python are implemented as arrays; * there is

Re: Fibonacci: returning a selection of the series

2010-08-29 Thread Steven D'Aprano
On Sun, 29 Aug 2010 10:36:45 -0700, Baba wrote: level: beginner i would like to return a selection of the Fibonacci series. example: start = 5 ; end = 55 the function should then return [5, 8, 13, 21, 34, 55] Start with something to lazily generate Fibonacci numbers. It doesn't matter