caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: vector dot multiply
@ 1995-06-09 11:50 Chet Murthy
  1995-06-09 13:20 ` nikhil
  0 siblings, 1 reply; 8+ messages in thread
From: Chet Murthy @ 1995-06-09 11:50 UTC (permalink / raw)
  To: caml-list



> >Also, is there a similar construct to Haskell array/list comprehensions?
>
> Bird and Wadler's book gives a simple translation scheme
> for list comprehensions to map+filter functions (pp63-64).
> This may meet your requirements.

That translation is wildly inefficient, too.  There's a reason
that lazy languages, and pure languages, haven't caught on --
it's called efficiency.  It's far more efficient to construct
a decent set of imperative classes (e.g. Rogue Wave Vector Classes)
than to try to import into CAML (which was, after all, designed
to (IMHO) not penalize the imperative code writer) the constructs of
intrinsically broken languages like Haskell.


>> ...
>> Also, is there a similar construct to Haskell array/list comprehensions?
>
>There is indeed one construct called streams.

Unfortunately, these streams are *not* the same as array/list comprehensions
-- they are "read-once", lazy, and impure.  So they're far more suitable
for I/O, and other such things, than for implementing such comprehensions.

--chet--






^ permalink raw reply	[flat|nested] 8+ messages in thread
* vector dot multiply
@ 1995-06-08 17:16 U-E59264-Osman Buyukisik
  1995-06-08 18:29 ` Pierre Weis
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: U-E59264-Osman Buyukisik @ 1995-06-08 17:16 UTC (permalink / raw)
  To: caml-list

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





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~1995-06-09 16:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-06-09 11:50 vector dot multiply Chet Murthy
1995-06-09 13:20 ` nikhil
  -- strict thread matches above, loose matches on Subject: below --
1995-06-08 17:16 U-E59264-Osman Buyukisik
1995-06-08 18:29 ` Pierre Weis
1995-06-08 23:02 ` Ascander Suarez
1995-06-08 23:17 ` Bob Buckley
1995-06-09  7:29 ` Pascal Nicolas
1995-06-09 10:42   ` Judicael Courant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).