u/mjohndoin r/functionalprogramming • Recommends
On “Functional programming beginner questions!”
These are great questions, honestly. I'll go one by one.
1. You would think so, right? This is one of the difficulties with using a functional style in a language without first-class immutable data structures, you end up doing things like "defensive copying", which is very bad indeed! Luckily, there are really cool immutable data types that rely on structural sharing as opposed to making copies on each write. Check out the five minutes [after this marker in this "Persistent Data Structures and Managed References" video], which gives a great explanation of how this works.
**TLDR;** With clever design, an immutable hash map can give you O(log32n), which is worse than O(1), but still pret…