3 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # This program is public domain
7 # SEE: <http://rosettacode.org/wiki/Dot_product>
9 fun dot_product
(v1
: Array[Float], v2
: Array[Float]): nullable Float
11 if v1
.length
!= v2
.length
then return null
13 for i
in [0..(v1
.length-1
)] do
19 var product
= dot_product
([1.0, 3.0, -5.0], [4.0, -2.0, -1.0])
20 if product
!= null then print product