caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "mohammad siddiqui" <writetosafi@hotmail.com>
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	[thread overview]
Message-ID: <BAY7-F32fKQu1bCdUg00000a4a8@hotmail.com> (raw)

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


         reply	other threads:[~2004-04-25  1:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-25 16:30 mohammad siddiqui
2004-04-25  1:53 ` mohammad siddiqui [this message]
2004-04-25 12:13   ` Jon Harrop
2004-04-25 12:45     ` Henri DF
2004-04-26 19:13       ` Jon Harrop
2004-04-26 22:38         ` Andrew Lenharth
2004-04-25 16:44   ` [Caml-list] help Brian Hurt
2004-04-25 17:28   ` [Caml-list] help Matt Gushee
2004-04-25 17:06 ` Jon Harrop
2004-04-25 17:39   ` Matt Gushee
2004-04-26  0:45 ` skaller
  -- strict thread matches above, loose matches on Subject: below --
2004-04-23  2:31 mohammad siddiqui
2004-04-23  4:17 ` Jon Harrop
2004-04-23  6:52   ` Jean-Christophe Filliatre
2004-04-23 15:43 ` Brian Hurt
2004-04-22 23:34 mohammad siddiqui
2004-04-22 23:57 ` Karl Zilles
2004-04-16 18:04 mohammad siddiqui
2004-04-16 18:59 ` skaller
2004-04-17  0:34   ` Shawn Wagner
2004-04-08 22:57 mohammad siddiqui
2004-04-09  6:56 ` Basile STARYNKEVITCH
2004-04-09  9:04 ` Richard Jones
2002-11-05 12:22 ÀîÒÇ
2002-11-05 13:39 ` Alessandro Baretta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BAY7-F32fKQu1bCdUg00000a4a8@hotmail.com \
    --to=writetosafi@hotmail.com \
    --cc=bhurt@spnz.org \
    --cc=caml-list@inria.fr \
    --cc=rich@annexia.org \
    --cc=skaller@users.sourceforge.net \
    --cc=zilles@1969.ws \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).