the tasks are:
- Write a function that adds vectors
- A function that calculates the dot product
- A function that can use the dot product to determine whether the angle is right.
My approaches:
.
addVectors:: (Num a) => a -> a -> a addVectors (a1, a2, a3) (b1, b2, b3) = (a1 b1) (a2 b2) (a3 b3)
.
scalarProduct:: (Num a) => a -> a -> a scalarProduct (a1, a2, a3) (b1, b2, b3) = (a1 * b1) (a2 * b2) (a3 * b3)
?
So I'm not sure how to phrase it. In the end, true should come out. This is likely to happen if the dot product equals 0.
I tried approaching tasks 1 and 2 myself.
CodePudding user response:
Everyone is dancing around this, but I'm going to be explicit.
addVectors (a1, a2, a3) (b1, b2, b3) = (a1 b1) (a2 b2) (a3 b3)
Your output is not valid tuple syntax.
You must instead write
addVectors (a1, a2, a3) (b1, b2, b3) = (a1 b1, a2 b2, a3 b3)