[Haskell-cafe] How to use STArray?
Alistair Bayley
abayley at gmail.com
Fri Aug 26 16:04:59 EDT 2005
> > makeArray :: Int -> Int -> a -> ST s (STArray s Int a)
> > makeArray lower upper val = newArray (-lower, upper) val
> ^
> Is negation of lower intentional here?
Yes, 'tis. Arguable as to whether or not it's a good idea, as it
changes the inerface. In my program I use two types of array:
- indexed from 1 to n
- indexed from a -ve lower to a +ve upper
So in this case it made sense to just pass the lower bound and negate
it in the wrapper.
More information about the Haskell-Cafe
mailing list