RosettaCodeData/Task/Dot-product/Elm/dot-product.elm
2023-07-01 13:44:08 -04:00

8 lines
199 B
Elm

dotp: List number -> List number -> Maybe number
dotp a b =
if List.length a /= List.length b then
Nothing
else
Just (List.sum <| List.map2 (*) a b)
dotp [1,3,-5] [4,-2,-1])