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 IAA14459; Fri, 23 Apr 2004 08:54:46 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA14478 for ; Fri, 23 Apr 2004 08:54:45 +0200 (MET DST) Received: from lri.lri.fr (lri.lri.fr [129.175.15.1]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i3N6siYM014681 for ; Fri, 23 Apr 2004 08:54:44 +0200 Received: from pc8-123 (pc8-123 [129.175.8.123]) by lri.lri.fr (8.12.10/jtpda-5.4) with ESMTP id i3N6qiCr028332 ; Fri, 23 Apr 2004 08:52:44 +0200 (MEST) Received: from filliatr by pc8-123 with local (Exim 3.35 #1 (Debian)) id 1BGuYG-0003e3-00; Fri, 23 Apr 2004 08:52:44 +0200 From: Jean-Christophe Filliatre MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16520.48444.172344.654688@gargle.gargle.HOWL> Date: Fri, 23 Apr 2004 08:52:44 +0200 To: Jon Harrop Cc: caml-list@inria.fr Subject: Re: [Caml-list] help In-Reply-To: <200404230517.59319.jdh30@cam.ac.uk> References: <200404230517.59319.jdh30@cam.ac.uk> X-Mailer: VM 7.03 under Emacs 20.7.2 Reply-To: Jean-Christophe.Filliatre@lri.fr (Jean-Christophe Filliatre) X-MailScanner: Found to be clean X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; filliatre:01 filliatre:01 lri:01 caml-list:01 2004:99 mutable:01 writes:01 precisely:02 wrote:03 explanation:04 array:04 array:04 init:05 structure:06 latter:06 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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