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 DAA00572; Sun, 25 Apr 2004 03:53:53 +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 DAA02110 for ; Sun, 25 Apr 2004 03:53:51 +0200 (MET DST) Received: from hotmail.com (bay7-f32.bay7.hotmail.com [64.4.11.32]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i3P1rojq027257 for ; Sun, 25 Apr 2004 03:53:50 +0200 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Sat, 24 Apr 2004 18:53:49 -0700 Received: from 66.141.17.195 by by7fd.bay7.hotmail.msn.com with HTTP; Sun, 25 Apr 2004 01:53:48 GMT X-Originating-IP: [66.141.17.195] X-Originating-Email: [writetosafi@hotmail.com] X-Sender: writetosafi@hotmail.com From: "mohammad siddiqui" To: bhurt@spnz.org Cc: zilles@1969.ws, skaller@users.sourceforge.net, rich@annexia.org, caml-list@inria.fr Subject: [Caml-list] help Date: Sun, 25 Apr 2004 01:53:48 +0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 25 Apr 2004 01:53:49.0388 (UTC) FILETIME=[271528C0:01C42A68] 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; model:01 model:01 struct:01 struct:01 typedef:01 typedef:01 ocaml:01 ocaml:01 blocking:01 mutable:01 mutable:01 int:01 int:01 float:02 float:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, I am having problem dealing with data structures in OCAML, I am translating code from C to OCAML. As shown below one structure contains array of other structures as its field. One of the guys here told me that we can’t “inline” structures into other structures in OCAML. I don’t how to deal with this, I already spent like 2 days on it. Should I make use of objects and let some member of it array of other objects? I am not sure this will do the purpose. I really appreciate if anyone helps me out this. For example if try to change the value model.supvec. (1).words. (1).wnum, it changes the values of all elements of the array model.supvec. I tried using references, mutable fields, Array.set function for modifying the contents of individual element. The structures in OCAML are: type word = { mutable wnum:int; (* word number *) mutable weight:float };; (* word weight *) type doc = { mutable docnum:int; (* Document ID *) mutable queryid: mutable costfactor:float; mutable twonorm_sq:float; mutable words:word array };; type model = { mutable sv_num:int; mutable at_upper_bound:int; mutable b:float; mutable supvec:doc array; mutable alpha: int array; } ;; The Structures in C are typedef struct word { int wnum; float weight; } WORD; typedef struct doc { long docnum; long queryid; double costfactor; double twonorm_sq; WORD *words; } DOC; typedef struct model { long sv_num; long at_upper_bound; double b; DOC **supvec; Double *alpha; } MODEL; _________________________________________________________________ FREE pop-up blocking with the new MSN Toolbar – get it now! http://toolbar.msn.com/go/onm00200415ave/direct/01/ ------------------- 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