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 NAA26653; Fri, 9 Aug 2002 13:19:28 +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 NAA26680 for ; Fri, 9 Aug 2002 13:19:27 +0200 (MET DST) Received: from postfix2-2.free.fr (postfix2-2.free.fr [213.228.0.140]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g79BJLr20126 for ; Fri, 9 Aug 2002 13:19:22 +0200 (MET DST) Received: from lfs (strasbourg-4-a7-62-147-194-185.dial.proxad.net [62.147.194.185]) by postfix2-2.free.fr (Postfix) with SMTP id DD6F35FC78; Fri, 9 Aug 2002 13:19:19 +0200 (CEST) Date: Fri, 9 Aug 2002 13:27:32 +0200 From: Nicolas FRANCOIS (AKA El Bofo) To: Florian Hars , Caml List Subject: Re: [Caml-list] Side effect Message-Id: <20020809132732.0139a7f4.nicolas.francois@free.fr> In-Reply-To: <3D536483.4090103@hars.de> References: <20020809004020.1dace6b2.nicolas.francois@free.fr> <3D536483.4090103@hars.de> X-Mailer: Sylpheed version 0.8.0 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Le Fri, 09 Aug 2002 08:43:15 +0200 Florian Hars a écrit : > Nicolas FRANCOIS (AKA El Bofo) wrote: > > So matrix m was modified. But I work on a copy of m in > > Pivot_Z.pivot_ligne_sans_echange. What's the problem doc ? > > Yes, m' is a copy of m, but the elements of m are arrays, so the copy m' > > contains references to the same arrays that m contains, so m.(i).(j) > is the same cell as m'.(i).(j). See: > > Objective Caml version 3.04 > > # let m = [|[|1;2|];[|3;4|]|];; > val m : int array array = [|[|1; 2|]; [|3; 4|]|] > # let m' = Array.copy m;; > val m' : int array array = [|[|1; 2|]; [|3; 4|]|] > # m'.(1).(1)<-99;; > - : unit = () > # m';; > - : int array array = [|[|1; 2|]; [|3; 99|]|] > # m;; > - : int array array = [|[|1; 2|]; [|3; 99|]|] > # m'.(1) <- [|0;0|];; > - : unit = () > # m' > ;; > - : int array array = [|[|1; 2|]; [|0; 0|]|] > # m;; > - : int array array = [|[|1; 2|]; [|3; 99|]|] > # > > Yours, Florian. Thanks, Florian. I guessed something like this, but could not find a clear explanation in the docs (not that the docs are bad, it's just the reader being unable to read it correctly). I'll have to write a matrix copy function :-) \bye -- Nicolas FRANCOIS http://nicolas.francois.free.fr A TRUE Klingon programmer does NOT comment his code ------------------- 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