|
|
|
|
|
by tomsmeding
420 days ago
|
|
EDIT: Wrong, the Haskell code is linear. See child comments. The extra cost is not in the recursive calls, of which there is only one per returned number. The cost is in achieving a yielded value n by starting with 1 and adding 1 to it (n-1) times. The given Haskell code: ints = 1 : map (+1) ints has the exact same problem, and it's just as quadratic. It might have a somewhat better constant factor, though (even apart from Python being interpreted) because there's less function calls involved. |
|
Your code didn't show a quadratic blowup in the timing: