iMPaCT try f#‎ > ‎

vectors in f#

open Impact

let v1 = [| 2.0; 3.0; 4.0; 5.0 |]
let v2 = [| 0.1; 0.5; 0.0; 0.8 |]
 
let scalarMult (vector : float [], multiplier : float) =
    [| for i in 0 .. vector.Length-1 -> vector.[i] * multiplier|]

let vectorAdd(v1 : float [], v2 : float []) =
    [| for i in 0 .. v1.Length-1 -> v1.[i] + v2.[i]|]
Comments