Hacker News new | past | comments | ask | show | jobs | submit login

Syntax matters. What I really like about Haskell is how much care has been given to the syntax to make functional idioms easy to read and write. One can just say,

    fib = 0:1:zipWith (+) fib (drop 1 fib)
[I know that `drop 1` is just `tail`, but this one makes the intent clearer for those who may not know Haskell].



You can often get close to Haskell-y implementations in Python with help from the itertools module. There are a couple "Haskell style" Fibonacci generators with itertools floating around in blog posts, I'm sure, and I've used itertools to write all sorts of things in a pretty succinct manner.


Technically drop 1 isn't just tail, but it doesn't matter in this example. Tail will error on an empty list.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: