Vectors in HC

Basics & using normal operators

From version 2.0, HC supports vectors. The notation is:
[x,y,z,...]

For example, the way you'd write a 3D vector with x = 5, y = 6, and z = 7 is:
[5,6,7]

You can use normal operators as long as it makes sense.
A few examples:
[1,2,3] * 2   (result will be [2,4,6])
[1,2,3] / 2  (result will be [0.5,1,1.5])
[1,2,3] + [4,5,6]   (result will be [5,7,9])
[1,2,3] - [4,5,6]   (result will be [-3,-3,-3])
etc.

If you try to use an operator that does not make sense, you will be warned by a message "Type error".

Cross and Dot product

HC also has the functions crossP() and dotP() built-in for cross and dot products respectively. Example of usage:
crossP([1,2,3],[4,5,6])     (result will be [-3,6,-3])
dotP([1,2,3],[4,5,6])         (result will be 32)

Back to HC documentation