type ElementMapFunction = ( x : number ) => number ; interface IVector { /**
     * Immutable element-wise addition
     */ add ( vect ) : IVector ; /**
     * Immutable element-wise subtraction
     */ subtract ( vect ) : IVector ; /**
     * Creates a new scaled vector
     */ scale ( scalar ) : IVector ; /**
     * Returns the dot product of two vectors
     */ dot ( vect ) : number ; /**
     * Returns a new vector with element-wise function mapping
     */ apply ( func ) : IVector ; } /**
 * Specify a mathematical Vector2D.
 */ export class Vector2 implements IVector { x : number ; y : number ; constructor ( x , y ) { this . x = x ; this . y = y ; } add ( vect ) { return new Vector2 ( this . x + vect . x , this . y + vect . y ) ; } subtract ( vect ) { return new Vector2 ( this . x - vect . x , this . y - vect . y ) ; } scale ( scalar ) { return new Vector2 ( this . x * scalar , this . y * scalar ) ; } dot ( vect ) { return this . x * vect . x + this . y * vect . y ; } /**
     * Apply the same function to both coordinates of this vector.
     */ apply ( func ) { return new Vector2 ( func ( this . x ) , func ( this . y ) ) ; } } /**
 * Specify a mathematical Vector3D.
 */ export class Vector3 implements IVector { x : number ; y : number ; z : number ; constructor ( x , y , z ) { this . x = x ; this . y = y ; this . z = z ; } add ( vect ) { return new Vector3 ( this . x + vect . x , this . y + vect . y , this . z + vect . z ) ; } subtract ( vect ) { return new Vector3 ( this . x - vect . x , this . y - vect . y , this . z - vect . z ) ; } scale ( scalar ) { return new Vector3 ( this . x * scalar , this . y * scalar , this . z * scalar ) ; } dot ( vect ) { return this . x * vect . x + this . y * vect . y + this . z * vect . z ; } /**
     * Apply the same function to all three coordinates of this vector.
     */ apply ( func ) { return new Vector3 ( func ( this . x ) , func ( this . y ) , func ( this . z ) ) ; } }