kat (boneidol@indy.im)'s status on Tuesday, 16-Apr-2019 14:00:03 UTC
katI've just done (part of) Advent of Code 2018 q9 in #Haskell. My first attempt, I thought was elegant and readable, but consumed all RAM in the universe. My second attempt, was more nuanced, throwing away all the things the solution did not really need, and this at least completed, however it takes 11 min to run.
The second part of the question expands the problem size by a factor of 100.
This is a nice explanation of the State Monad https://wiki.haskell.org/State_Monad #Haskell I've basically cut and paste the example more than once before to solve problems.
Ok, I made some changes, and it does the first part in a 0.1s now, and the second part in 7s. However the code looks very much like an imperative language now. There is a loop over a list inside which we do things, and use the State Monad to change things.
The result is still slower than Python and less readable now.
I suppose I should be pleased. A execution time from 11min -> 0.1 sec
This functional programming malarky seems a bit dangerous. Making everything stateless and recursive seems nice, but picking the correct data structures and choices makes a huge difference.