Hi,
I'd like to be able to do replicateM, but over a vector instead of a list.
Right now I'm doing this:
import qualified Data.Vector.Generic as G
import qualified Data.Vector.Unboxed.Mutable as M
replicateM n action = do
mu - M.unsafeNew n
let go !i | i n = action = M.unsafeWrite mu i
Chad.Scherrer:
Hi,
I'd like to be able to do replicateM, but over a vector instead of a list.
Right now I'm doing this:
import qualified Data.Vector.Generic as G
import qualified Data.Vector.Unboxed.Mutable as M
replicateM n action = do
mu - M.unsafeNew n
let go !i | i n =
On 02/04/2010, at 12:16, Don Stewart wrote:
Chad.Scherrer:
Hi,
I'd like to be able to do replicateM, but over a vector instead of a list.
Right now I'm doing this:
The operation you are looking for is called newWith. It probably should be
called replicate.
Roman? Can we generate frozen
rl:
replicate :: Int - a - New a
replicate n x = Generic.New.unstream (Fusion.Stream.replicate n x)
and then either
Mutable.run (replicate n x)
to get a mutable vector or
new (replicate n x)
Hmm, but here 'a' is pure. I don't think he wants
newWith :: (PrimMonad m, MVector
On 02/04/2010, at 13:01, Don Stewart wrote:
rl:
replicate :: Int - a - New a
replicate n x = Generic.New.unstream (Fusion.Stream.replicate n x)
and then either
Mutable.run (replicate n x)
to get a mutable vector or
new (replicate n x)
Hmm, but here 'a' is pure. I don't