Question: Write a recursive Haskell function Write a Haskell function zigzag :: Integer -> Char -> Char -> String such that zigzag n ch1 ch2 returns
Write a recursive Haskell function

Write a Haskell function zigzag :: Integer -> Char -> Char -> String such that zigzag n ch1 ch2 returns a string of length n, with the following pattern: there is one copy of ch1, followed by two copies of ch2, followed by two copies of ch1, followed by two copies of ch2, and so on. If n is negative, the empty list is returned. For example, the function has the following behavior: *Main zigzag 10 ,g, ,r, "grrggrrggr" *Main> zigzag 13Q Write a Haskell function zigzag :: Integer -> Char -> Char -> String such that zigzag n ch1 ch2 returns a string of length n, with the following pattern: there is one copy of ch1, followed by two copies of ch2, followed by two copies of ch1, followed by two copies of ch2, and so on. If n is negative, the empty list is returned. For example, the function has the following behavior: *Main zigzag 10 ,g, ,r, "grrggrrggr" *Main> zigzag 13
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
