I'll go right away - is there a way to get a dynamically-sized data structure with constant access time in Haskell, like an array in any other imperative language?
I am sure that somewhere there is a module that does this for us magically, but I hope for a general explanation of how this can be done in functional mode :)
As far as I know, Map uses a binary tree view, so it has O(log(n)) access time, and lists, of course, have O(n) access time.
Besides, if we made it so that it is unchanged, it would be clean, right?
Any ideas how I could do this (besides something like Array = Array { one :: Int, two :: Int, three :: Int ...} in a Haskell template or the like)?
haskell
Tetigi
source share