Hacker News new | ask | show | jobs
by throwawaymaths 1426 days ago
I mean to be quite honest I remember this problem and all I could think of was "this being hard is a sign that the data structure is poorly designed. But I also remember giving you a four line code sample using the process dictionary that you could have used, because this was "clearly an exceptionally pathologic data structure".
1 comments

Oh yeah I remember your reply (not word for word but the approach of using it). If you search around for using process dictionary it seems to go against the grain of Elixir since it introduces mutable state which is fundamentally against what the language provides. It did lead to much easier to understand code because it brings the language more in line with how other languages work where you can update a variable outside of a specific scope. Maybe it's a good example of the idea of "sharp knives" but applied to Elixir instead of Ruby.

I don't think the data structure was that crazy or rare. It boiled down to looping over 2 lists and wanting to keep an independent count of each one.