I don't quite understand how Data.Array.Diff work. I tried this: > let arr = listArray (1,3) [1..3] :: DiffArray Int Int
then: > replaceDiffArray arr [(1, 777)] array (1,3) [(1,1),(2,777),(3,3)] Why when replacing first element the second one changes? and also trying to add 4-th element results in: Prelude Data.Array.Diff> replaceDiffArray arr [(4, 444)] array (1,3) [(1,1),(2,2),(3,3)] It looks like replaceDiffArray can not be used to add new element to the end of array? Thanks, Dima On Thu, Jul 10, 2008 at 10:59 PM, Jefferson Heard < [EMAIL PROTECTED]> wrote: > Two questions. How often does the array change, and how big does it > get? It may well be that you just copy it and take the hit, as > that'll be cheaper (even in C, incidentally) than any other solution, > if it's a short array or if the updates happen rarely. > > If not, try using Data.Array.Diff and replaceDiffArray. This is > usually fairly efficient for most applications. > > By the way, depending on the type of the data you're putting into > these arrays, Data.ByteString might be a good choice as well. > > On Thu, Jul 10, 2008 at 12:12 PM, Felipe Lessa <[EMAIL PROTECTED]> > wrote: > > 2008/7/10 Dmitri O.Kondratiev <[EMAIL PROTECTED]>: > >> 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 > > > > HTH, > > > > -- > > Felipe. > > _______________________________________________ > > Haskell-Cafe mailing list > > [email protected] > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > -- > 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 >
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
