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 OAA31095; Sun, 25 Apr 2004 14:45:25 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA31141 for ; Sun, 25 Apr 2004 14:45:24 +0200 (MET DST) Received: from mail3.epfl.ch (mail3.epfl.ch [128.178.50.19]) by nez-perce.inria.fr (8.12.10/8.12.10) with SMTP id i3PCjNjq015746 for ; Sun, 25 Apr 2004 14:45:23 +0200 Received: (qmail 24023 invoked by uid 107); 25 Apr 2004 12:45:23 -0000 Received: from mailav2.epfl.ch (HELO mailav2) (128.178.50.191) by mail3.epfl.ch with SMTP; 25 Apr 2004 12:45:23 -0000 Received: From mail0.epfl.ch ([128.178.50.57]) by mailav2 (WebShield SMTP v4.5 MR1a P0803.345); id 1082897334897; Sun, 25 Apr 2004 14:48:54 +0200 Received: from lcmpc4.epfl.ch (128.178.8.59) by mail0.epfl.ch (AngelmatoPhylax SMTP proxy); Sun, 25 Apr 2004 14:45:22 +0200 Date: Sun, 25 Apr 2004 14:45:22 +0200 (CEST) From: Henri DF X-X-Sender: henridf@lcmpc4.epfl.ch To: Jon Harrop cc: caml-list@inria.fr Subject: Re: [Caml-list] help In-Reply-To: <200404250509.10779.jdh30@cam.ac.uk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 model:01 model:01 adept:01 bug:01 faq:01 faq:01 beginner's:01 beginners:01 bin:01 compiler:01 caml-bugs:01 ocaml:01 ocaml:01 caml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > I sent you this as an e-mail on Friday: > > The following types are a start for your conversion: > > type fnum=int and fval=float; > > type word = { wnum: fnum ref; weight: fval } > type doc = { docnum: int; queryid: int; costfactor: float; twonorm_sq: float; > words: word array } > type model = { sv_num: int; at_upper_bound: int; b: float; supvec: doc array; > alpha: float }; > > The following line creates an example "model" with its values filled in: > > let test_model = { sv_num=0; at_upper_bound=0; b=0.; supvec=Array.make 1 > { docnum=0; queryid=0; costfactor=0.; twonorm_sq=0.; words=Array.make 1 > { wnum=ref 0; weight=0. } }; alpha=0. }; > > I deliberately made "wnum" a reference so that it can be set: any reason not to make it a mutable ? henri > test_model.supvec.(0).words.(0).wnum := 1; > > If you want to do a really direct conversion then you probably want to make > each of the fields in each of the records a reference (as I did with "wnum"). > However, you may wish to exercise the functional programming side of ocaml > and write functions which replace data structures, instead of altering them > in an imperative style. Although this is unintuitive at first, because an > imperative language would do lots of copying and deleting of data structures, > the ocaml compiler is very adept at performing only the changes which are > made to a data structure... > > HTH. > > Cheers, > Jon. > > ------------------- > 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 > ------------------- 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