module Solutions.P15 (repli) where
repli :: [a] -> Int -> [a]
repli :: forall a. [a] -> Int -> [a]
repli [a]
_ Int
0 = []
repli [] Int
_ = []
repli (a
x:[a]
xs) Int
n = a -> Int -> [a] -> [a]
forall a. a -> Int -> [a] -> [a]
prepend a
x Int
n ([a] -> Int -> [a]
forall a. [a] -> Int -> [a]
repli [a]
xs Int
n)
prepend :: a -> Int -> [a] -> [a]
prepend :: forall a. a -> Int -> [a] -> [a]
prepend a
_ Int
0 [a]
l = [a]
l
prepend a
x Int
n [a]
l
| Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0 = a -> Int -> [a] -> [a]
forall a. a -> Int -> [a] -> [a]
prepend a
x (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) (a
xa -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
l)
| Bool
otherwise = [a]
forall a. HasCallStack => a
undefined