"Strong typing vs. strong testing"
no.email at nospam.invalid
Sat Oct 2 05:57:22 CEST 2010
Raffael Cavallaro <raffaelcavallaro at pas.despam.s.il.vous.plait.mac.com>
>> prints appears to be the 2000th Fibonacci number rather than the 1000th.
> I think you're mistaken. fib(0) = 0, fib(1) = 1, fib(2) = 1, fib(3) =
> 2 ... fib(11)= 89 ...
Whoops, you're right, I messed up my program while refactoring it. Sorry.
> you like we can do it iteratively instead, which, as in haskel, takes
> no perceptible time:
I couldn't tell whether the earlier version with the expt 5 was a
direct solution of the recurrence, or what.
> 2. the result of fib(1000) is going to overflow c integer types
Yes, it's a real shame that most cpu's these days don't have a hardware
trap for int overflow. That would allow much safer programming for the
large amount of code where the programmer expects to never overflow
but can be caught by surprise.
More information about the Python-list