|
|
|
|
|
by tmoertel
4572 days ago
|
|
Yes! Haskell is a delight for optimization because you can use algebraic reasoning and calculation to derive more efficient code. For example, if I had the following code: (concat . reverse . map reverse) strs
I could easily replace it with the following code, which is simpler, faster, and reduces memory churn: (reverse . concat) strs
You can prove that these two implementations produce the same results (see [1] for a step-by-step proof). After you do the proofs for a while, you'll start seeing similar optimizations everywhere – and claiming them.[1] https://gist.github.com/tmoertel/7968466 |
|