***Exception: Prelude.head empty List. What is the base case?
问题 I am writing a function of getting the product of 2 matrix. transpose' :: [[a]] -> [[a]] transpose' [[]] = [] transpose' m = (map head m) : transpose' (map tail m) dotProduct :: [Int] -> [Int] -> Int dotProduct [] [] = 0 dotProduct (x:xs) (y:ys) = (x*y) + dotProduct xs ys matrixProduct :: [[Int]] -> [[Int]] -> [[Int]] matrixProduct [] _ = [] matrixProduct (x:xs) y = (map (dotProduct x) (transpose' y)):matrixProduct xs y I always get something like [[2,2, ***Exception: Prelude.head empty List