Haskell
Complete the following function definition: stutter n x should return a list of length n where each element is x. E.g., stutter 3 5 = [5,5,5]. Use a list comprehension to produce the result. Note stutter 0 x = []. Don't worry about n < 0; the canonical solution makes stutter return [].
stutter n x = ???
The code will be
stutter :: Int->a->[a]
stutter 0 y = []
stutter x y = [y|_<-[1..x]]
Get Answers For Free
Most questions answered within 1 hours.