vector dot multiply

U-E59264-Osman Buyukisik (osman.buyukisik@ae.ge.com)
Thu, 8 Jun 1995 13:16:29 -0400

Message-Id: <199506081716.NAA01690@thomas.ge.com>
Date: Thu, 8 Jun 1995 13:16:29 -0400
From: U-E59264-Osman Buyukisik <osman.buyukisik@ae.ge.com>
To: caml-list@pauillac.inria.fr
Subject: vector dot multiply

Hi,
What would be 1). elegant
2). efficient
way to write a "dot multiply" function in caml-light?
This is what I came up with but I am hoping for a better one :

let dot a b = let rec dot_aux a b i sum =
if i< vect_length a then
dot_aux a b (i+1) (sum +. (a.(i) *. b.(i)) )
else
sum
in
dot_aux a b 0 0.0;;

Also, is there a similar construct to Haskell array/list comprehensions?

Thanks in advance.
Osman