Orthogonal Vector

Published by Mubashir Hassan in

Create a function that takes two vectors as arrays and checks if the two vectors are orthogonal or not. The return value is boolean. Two vectors first and second are orthogonal if their dot product is equal to zero.

Examples

is_orthogonal([1, 2], [2, -1]) ➞ true

is_orthogonal([3, -1], [7, 5]) ➞ false

is_orthogonal([1, 2, 0], [2, -1, 10]) ➞ true

Notes

  • The two arrays are of same length.
  • Check out the Resource tab.
Watch a quick demo on how Edabit works.