2 ms·
This is about the most bogus test the author could have constructed. You have to explicitly memoize functions in languages that aren't purely functional like H
by dreish 19y ago
This is about the most bogus test the author could have constructed. You have to explicitly memoize functions in languages that aren't purely functional like Haskell. Fibonacci is around O(1.6^n) if you conveniently "forget" to memoize it, or else O(n).
So the upside of a pure functional language is you don't have to explicitly memoize. To see the downside, try explaining monads to an undergrad.
Haskell is a cool enough language that it doesn't need misleading hype like this post.
- SamReidHughes 19y agoWhat gives you the idea that Haskell implicitly memoizes functions? And it obviously isn't memoizing. If the function were memoized, the timing would be much, much less than 0.48 seconds.
- dreish 19y agoI have to admit I understand Haskell a lot less than I thought I did (which wasn't much to begin with -- I've done maybe four or five Euler Project puzzles with it and nothing else). I tried this same Fibonacci function on my machine using GHC 6.8.1, and it's clearly O(1.62^N). I withdraw my earlier dumb statement.