From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA18329; Sun, 8 Jun 2003 13:28:05 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA18511 for ; Sun, 8 Jun 2003 13:28:04 +0200 (MET DST) Received: from mwinf0603.wanadoo.fr (smtp3.wanadoo.fr [193.252.22.25]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h58BS3H00939 for ; Sun, 8 Jun 2003 13:28:03 +0200 (MET DST) Received: from r2d2 (unknown [81.48.227.180]) by mwinf0603.wanadoo.fr (SMTP Server) with SMTP id 44EF424000A7 for ; Sun, 8 Jun 2003 13:28:03 +0200 (CEST) Message-ID: <000a01c32db1$041915c0$0100a8c0@r2d2> From: "TBraibant" To: Subject: [Caml-list] Function composition in CAML Date: Sun, 8 Jun 2003 13:27:59 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0007_01C32DC1.C74287B0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Spam: no; 0.00; bug:01 caml:01 W5:97 W3:96 let:04 arial:95 array:04 efficient:05 seems:05 calculation:08 function:09 message:89 theory:11 idea:11 U4:88 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk This is a multi-part message in MIME format. ------=_NextPart_000_0007_01C32DC1.C74287B0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello I have made some experimentations, but I can't find where is a bug in a = simple piece of code I represent a polynome by a list of its coefficents (I know that there is a more efficient way to do this calculation (P(x) = in fact), but it is just an expermimentation) let horner p x =3D let v=3D Array.of_list p in let n =3D Array.length v in let r =3D ref n in=20 let f =3D ref (function u ->u ) in while !r <> 0 do f :=3D (function u -> !f( v.(!r)+ x*u)); r :=3D !r -1 ; done; !f(0) ;; In theory, the !f(0) call shall give me P(x)... But it seems that the computer crash, and can't handle this line of = code... Someone has an idea? Thank you ------=_NextPart_000_0007_01C32DC1.C74287B0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello
 
I have made some experimentations, but = I can't find=20 where is a bug in a simple piece of code
 
I represent a polynome by a list of its = coefficents
(I know that there is a more efficient = way to do=20 this calculation (P(x) in fact), but it is just an=20 expermimentation)
 
let horner p x =3D
  let v=3D = Array.of_list p=20 in
  let n =3D Array.length v in
  let r =3D ref n in =
  let=20 f =3D ref (function u ->u  ) in
    while !r = <> 0=20 do
      f :=3D (function u -> !f( = v.(!r)+=20 x*u));
      r :=3D !r -1 = ;
   =20 done;
    !f(0)
;;
 
In theory, the !f(0) call shall give me = P(x)...
But it seems that the computer crash, = and can't=20 handle this line of code...
 
Someone has an idea?
 
Thank you
 
 
------=_NextPart_000_0007_01C32DC1.C74287B0-- ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners