[Haskell-cafe] Copying Arrays
rtharper at aftereternity.co.uk
Thu May 29 12:21:25 EDT 2008
I'm trying to implement some file I/O where I can read in a file to an
array, but do so without having to know how much space I will need.
(Before you suggest it, lists are too slow/space consuming.) I was
thinking that one possible solution is to use a strategy used in
dynamic arrays, where everytime you run out of space you double the
capacity of the array. Trouble is, most arrays in Haskell would
require you to traverse the entire array and copy each individual
cell, which would make it worthless.
Are there any low-level array types (MutableByteArray#, for example)
that support a memcpy-like function where I could copy the entire
array into the new one instead of copying it one value at a time? Is
there another solution that I'm missing?
MSc Computer Science '08
University of Oxford
Mobile: +44 (0)7533 998 591
Skype: +1 949 273 4627 (harpertom)
More information about the Haskell-Cafe