Haskell non exhaustive patterns in function for recursion -
it gives multiple declaration of "mph"
here code
dotproduct x y = sum(zipwith (*) x y) matrixproduct x y = mph [] x y mph acc [] b = acc counthelp countacc c [] = countacc counthelp countacc c (d:ds) = counthelp ((dotproduct c d) : countacc) c ds mph acc (a:as) b = mph ((counthelp [] b) : acc) b
can explain little bit me? suppose input
x = [[1,2,3],[4,5,6]] y = [[7,9,11],[8,10,12]] matrixproduct x y
it should give martix [[64,58],[154,139]]
what think each time taking out first list of first matrix when the matrix become empty list recursion stop.
Comments
Post a Comment