[Haskell-cafe] Newbie: Appending arrays?

Felipe Lessa felipe.lessa at gmail.com
Thu Jul 10 12:12:19 EDT 2008

2008/7/10 Dmitri O.Kondratiev <dokondr at gmail.com>:
> allows construct an array of a fixed size. How to add more elements to the
> array later?

I can't really answer your question, however I bet that it would
require allocating another, bigger array and copying the old elements
over, at least from time to time. So you may want to take a look at
Data.Sequence[1], supporting O(1) append on both sides and (sort of)
O(log i) for accessing the i-th element.

[1] http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Sequence.html



More information about the Haskell-Cafe mailing list