1. An irrefutable improvement over the state of the art. 2. A short paper which can be understood after only a dozen readings or so. I mean really understood, with visualizations and everything. 3. A practical algorithm which can be implemented by nearly anyone (even me).
I'm by no means a Haskell evangelist, but I believe it's a great educational tool for devs.
You've made a Fibonacci number algorithm. Recursive it's slow, iterative it's nasty. There's another way > let fib = 0 : 1 : zipWith (+) fib (tail fib) Then to get the 10kth Fibonacci number you can > fib !! 10000 It's fast. It's tiny. It has no risk of stack overflow because it's not a recursive function. It illustrates how and why lazy evaluation is important and even better than eager evaluation in many cases. I use this principle in my C#/Java work a lot. It's my favorite.
My favorite is the FLAC algorithm. It's fairly simple to explain - take a signal input, pattern match a generative signal that closely matches the original or part of it, and the output is a combination of that generative code and the difference between it and it and the input.
Comments (491) 209 threads
Earlier comments-ss
1. An irrefutable improvement over the state of the art.
2. A short paper which can be understood after only a dozen readings or so. I mean really understood, with visualizations and everything.
3. A practical algorithm which can be implemented by nearly anyone (even me).
You've made a Fibonacci number algorithm. Recursive it's slow, iterative it's nasty. There's another way
> let fib = 0 : 1 : zipWith (+) fib (tail fib)
Then to get the 10kth Fibonacci number you can
> fib !! 10000
It's fast. It's tiny. It has no risk of stack overflow because it's not a recursive function. It illustrates how and why lazy evaluation is important and even better than eager evaluation in many cases. I use this principle in my C#/Java work a lot.
It's my favorite.
Second favorite is the LISP REPL. Specifically the Eval function, thanks to this classic video of Sussman https://www.youtube.com/watch?v=0m6hoOelZH8
All comments shown.
Couldn't load more comments. Check your connection and try again.