I currently have a 2D array declared as:
import Data.Array.Unboxed
listArray ((0,0), (9,9)) (replicate 100 \'f\') ∷ UArray (Int, Int) Char
I a
The simplest update function for arrays is (//)
, which has this type:
(//) :: (IArray a e, Ix i) => a i e -> [(i, e)] -> a i e
For example:
Data.Array.Unboxed> listArray (0, 4) "abcde" // [(1, 'f')] :: UArray Int Char
array (0,4) [(0,'a'),(1,'f'),(2,'c'),(3,'d'),(4,'e')]
You can access particular elements with (!)
:
Data.Array.Unboxed> it ! 1
'f'