Browse thread
[Caml-list] help
- mohammad siddiqui
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | mohammad siddiqui <writetosafi@h...> |
| Subject: | [Caml-list] help |
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