Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] help
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@l...>
Subject: Re: [Caml-list] help

Jon Harrop writes:
 > 
 > On Friday 23 April 2004 3:31 am, mohammad siddiqui wrote:
 > > I already made it mutable. words is an array of structure  called "word".
 > > If I try to change the value as you told it changes tha values of all the
 > > elements of array "words". Thanks for your help in advance.
 > 
 > So if you're using either "Array.make" or "Array.create" to build
 > your array  then you're creating an array filled with references to
 > the same thing. Does that answer your question?

It is likely to be the explanation. More precisely, you should write

	Array.init n (fun _ -> { wnum = ...; weight = ... })

and not

	Array.make n { wnum = ...; weight = ... }

In the latter case, all array cells point to the same value.

-- 
Jean-Christophe

-------------------
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