I am trying to solve following problem in Haskell using recursion:Define a recursive function funkyMap :: (a -> b) -> (a -> b) -> [a] -> [b] that takes as arguments two functions f and g and a list xs, and applies f to all elements at even positions [0, 2..] in xs and g to all elements at odd positions [1, 3..] in xs.Example: funkyMap (+10) (+100) [1, 2, 3, 4, 5] = [(+10) 1, (+100) 2, (+10) 3, (+100) 4, (+10) 5].I came up with following solution:h1 p q [] = []h1 p q ((cnt, val) : xs) = (if odd cnt then (q val) else (p val) ) : h1 p q xsfunkyMap f g xs = h1 f g ( zip [0..] xs)If I try funkyMap (+10) (+100) [1, 2, 3, 4, 5] I get [11,102,13,104,15] which is expected.Also funkyMap (+100) (+2) [1] gives [101]and funkyMap (+100) (+2) [] gives []Please review this solution and let me know your feedback.
A map function that alternates between two mapping functions
haskell;recursion