[Edu-sig] Crunchy Fibonaccis

Andre Roberge andre.roberge at gmail.com
Thu Jul 27 21:23:14 CEST 2006


Nice!  Now, put this example on a webpage, with the function
definition inside a <pre>,
add a simple html tag so that it becomes
<pre title="interpreter">
and it will be truly deserving of the epithet "crunchy"  ;-)

More serious comment below.

On 7/27/06, kirby urner <kirby.urner at gmail.com> wrote:
> We've many times visited the Fibonaccis on this list.
>
[snip]
>
> >>> def fibolater(a,b):
>         while True:
>                 t = (yield a)
>                 if t is not None:
>                         a,b = t
>                 a,b = b, a + b
>
>
[snip]
>
> The punch line with the Phi-bonaccis is f.next()/f.next() -- and yes,
> that's legal Python -- approaches 1/phi.

Is the "order of operation" (i.e. first evaluated is the left-most
one) always guaranteed
to be that by Python?  Or is it only guaranteed by the current CPython
version?...

I seem to recall, from many years in the past, that some language (C,
I believe...) allowed
statements like:
i = 1
a = 2*i++  +  i++
but that the order of execution (i.e. which "i++" is executed first)
could not be guaranteed...
(Quiz: what is "a" equal to? )

Anyone knows?  (for Python I mean...)

André


More information about the Edu-sig mailing list