The extent to which immutability leads to duplication seems a matter of implementation rather than a principle.
The compiler/runtime could optimize such that memory is reused, as long as all other laws are obeyed.
The compiler/runtime could optimize such that memory is reused, as long as all other laws are obeyed.
log(n) slowdown to add in the end
but the cost to add in the middle is cheaper then the trivial array (see insertAt)
I also mentioned sets, not lists.
But sets are also a mere log(n) away
https://hackage.haskell.org/package/containers-0.6.6/docs/Da...