Reputation: 819
I am new to Haskell and Massiv so please forgive if question is dumb.
I have a mutable array of primitives:
x = (makeVectorR P Seq (Sz 10) (\_ -> 0))
I want to set 1 value in my array. It would be nice to do something like this:
(x ! 3) = 42
Is this something that Massiv supports?
Upvotes: 1
Views: 71
Reputation: 10645
Here's how you can create a mutable primitive array and set a single value in it:
{-# LANGUAGE TypeApplications #-}
import qualified Data.Massiv.Array.Mutable as M
import Data.Massiv.Array (P, Sz (Sz1))
main :: IO ()
main = do
x <- M.newMArray @P (Sz1 10) 0
M.write_ x 3 42
Upvotes: 2