English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
vector dot multiply
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1995-06-08 (18:21)
From: U-E59264-Osman Buyukisik <osman.buyukisik@a...>
Subject: vector dot multiply
 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)) )
 dot_aux a b 0 0.0;;

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

Thanks in advance.