From: Florian Hars <florian@hars.de>
To: "Nicolas FRANCOIS (AKA El Bofo)" <nicolas.francois@free.fr>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Side effect
Date: Fri, 09 Aug 2002 08:43:15 +0200 [thread overview]
Message-ID: <3D536483.4090103@hars.de> (raw)
In-Reply-To: <20020809004020.1dace6b2.nicolas.francois@free.fr>
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.
-------------------
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
next prev parent reply other threads:[~2002-08-09 6:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-08 22:40 Nicolas FRANCOIS
2002-08-09 6:43 ` Florian Hars [this message]
2002-08-09 11:27 ` Nicolas FRANCOIS
2002-08-09 12:08 ` Pierre Weis
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=3D536483.4090103@hars.de \
--to=florian@hars.de \
--cc=caml-list@inria.fr \
--cc=nicolas.francois@free.fr \
/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