[Haskell-cafe] Incremental array updates

2009-02-26 Thread Daniel Kraft
Hi, I seem to be a little stuck with incremental array updates... I've got an array of few (some thousand) integers, but have to do a calculation where I incrementally build up the array. For sake of simplicity, for now I don't use a State-Monad but simply pass the array as state down the

Re: [Haskell-cafe] Incremental array updates

2009-02-26 Thread Eugene Kirpichov
You need to use STUArray. The Data.Array completely-immutable-and-boxed arrays are ok only for tasks where you build an array once and don't modify it, and where you need array elements to be lazy. The // operation creates a copy of the whole array with one element modified. It should probably be

Re: [Haskell-cafe] Incremental array updates

2009-02-26 Thread Luke Palmer
On Thu, Feb 26, 2009 at 6:53 AM, Daniel Kraft d...@domob.eu wrote: procOne (a + 1) (newarr `seq` newarr) The semantics of seq are: a `seq` b = _|_ if a = _|_, b otherwise. This implies that x `seq` x = x, and this seq is superfluous. Maybe you meant newarr `seq` procOne (a+1) newarr ?

Re: [Haskell-cafe] Incremental array updates

2009-02-26 Thread Daniel Fischer
Am Donnerstag, 26. Februar 2009 14:53 schrieb Daniel Kraft: Hi, I seem to be a little stuck with incremental array updates... I've got an array of few (some thousand) integers, but have to do a calculation where I incrementally build up the array. For sake of simplicity, for now I don't

Re: [Haskell-cafe] Incremental array updates

2009-02-26 Thread Ross Paterson
On Thu, Feb 26, 2009 at 02:53:42PM +0100, Daniel Kraft wrote: I seem to be a little stuck with incremental array updates... I've got an array of few (some thousand) integers, but have to do a calculation where I incrementally build up the array. For sake of simplicity, for now I don't