haskell - Higher order function, parse error in pattern: xs -
here code:
-- combine lists binary operation clwbo :: (num a, num b, num c) => (a -> b -> c) -> [a] -> [b] -> [c] clwbo fps lista listb |length lista /= length listb = [] |length lista ==length listb = case lista listb of [] [] -> [] x:xs y:ys -> [fps x y] ++ clwbo fps xs ys otherwise -> error "get off"
and here error message terminal:
test.hs:8:42: parse error in pattern: xs failed, modules loaded: none.
anyone likes tell me what's wrong code?
you cannot put multiple patterns side side in case
expression. match multiple patterns @ once, put them in tuple:
case (lista, listb) of ([], []) -> ... (x:xs, y:ys) -> ... otherwise -> ...
Comments
Post a Comment