Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Operations on Vectors [5/13]

A unit vector is any vector that has a length of 1. A unit vector can be created from an existing vector by applying the getter .unit.

The getter .unit from type vector2D is a pure function.

There is an exception: a unit vector cannot be created from a null-vector, because the null-vector does not have a direction. Consequentially, applying a getter .unit to a null vector raises a runtime error.

Uncomment the erroneous lines to see the error description.

Loading...