Hello,<br><br>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 memory?<br><br> <a href="http://www.haskell.org/ghc/docs/latest/html/libraries/array-0.3.0.0/Data-Array-MArray.html">http://www.haskell.org/ghc/docs/latest/html/libraries/array-0.3.0.0/Data-Array-MArray.html</a><br>
<br>As far as I can tell, that is the interface for creating ST Arrays.  For example, newListArray looks almost perfect:<br><br><b>newListArray</b> :: (<a href="http://www.haskell.org/ghc/docs/latest/html/libraries/array-0.3.0.0/Data-Array-MArray.html#t%3AMArray">MArray</a> a e m, <a href="http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/Data-Ix.html#t%3AIx">Ix</a> i) =&gt; (i, i) -&gt; [e] -&gt; m (a i e)<br>
<br>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&#39;s potentially a lot of copying, right?<br>
<br>Is some other array better suited for this, such as vector or uvector?<br><br>Thanks,<br>Jason<br>