[Haskell-cafe] Copying Arrays
jefferson.r.heard at gmail.com
Thu May 29 12:54:02 EDT 2008
Define too slow, time-consuming? I've dealt with this problem a lot
at this point, and I've been able to slurp up CSV files of several
gigabytes in the same amount of time as I generally do in C. I have a
feeling an array solution is just going to bog you down more, however
if you insist, I would also suggest writing your I/O in C and
returning a ForeignPtr to something and work from there.
On Thu, May 29, 2008 at 12:21 PM, Tom Harper
<rtharper at aftereternity.co.uk> wrote:
> 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?
> Tom Harper
> MSc Computer Science '08
> University of Oxford
> Mobile: +44 (0)7533 998 591
> Skype: +1 949 273 4627 (harpertom)
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
I try to take things like a crow; war and chaos don't always ruin a
picnic, they just mean you have to be careful what you swallow.
-- Jessica Edwards
More information about the Haskell-Cafe