[Haskell-cafe] Streamed creation of STArray from list?
dagit at codersbase.com
Thu Feb 11 12:23:05 EST 2010
I was wondering if there is a trick for generating a new STArray from a list
in such a way that you do not have to hold both the list and array in
As far as I can tell, that is the interface for creating ST Arrays. For
example, newListArray looks almost perfect:
=> (i, i) -> [e] -> m (a i e)
If I know the length of the list, I might expect newListArray to have the
memory behavior I want. In my case, the code calls (length xs) to calculate
the length of the list. As I understand it, that will force the spine of
the list into memory. Can this be avoided? The only trick that comes into
mind is the one used by the C++ vector class where you dynamically resize
the array and copy the values to the new array. That's potentially a lot of
Is some other array better suited for this, such as vector or uvector?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe