{-# LANGUAGE BangPatterns #-}
module Statistics.Matrix.Function where
square :: Double -> Double
square :: Double -> Double
square Double
x = Double
x Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
x
for :: Monad m => Int -> Int -> (Int -> m ()) -> m ()
for :: forall (m :: * -> *).
Monad m =>
Int -> Int -> (Int -> m ()) -> m ()
for Int
n0 !Int
n Int -> m ()
f = Int -> m ()
loop Int
n0
where
loop :: Int -> m ()
loop Int
i | Int
i Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
n = () -> m ()
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
| Bool
otherwise = Int -> m ()
f Int
i m () -> m () -> m ()
forall a b. m a -> m b -> m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> m ()
loop (Int
iInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1)
{-# INLINE for #-}