have to write functions with the same effekt like the replicate-function.
- List comprehension:
My try:
rep list = [ a | a <- list, _ <- [1..a]]
Works great with Ints, but I want to use this with chars too. Something like this:
rep 4 "Hello" => "Hello", "Hello", "Hello", "Hello"
2 Recursion:
rep :: (Num i, Ord i) => i -> a -> [a]
rep n x
| n <= 0 = []
| otherwise = x:rep (n-1) x
Same Problems with chars!