```caml-list - the Caml user's mailing list
help / Atom feed```
```From: Nicolas FRANCOIS (AKA El Bofo) <nicolas.francois@free.fr>
To: Caml List <caml-list@inria.fr>
Subject: [Caml-list] Problem with Graph module
Date: Mon, 17 Jun 2002 03:12:19 +0200
Message-ID: <20020617031219.2dd51ec3.nicolas.francois@free.fr> (raw)

A strange thing, under Linux : this piece of code :

open Graphics;;
open Random;;

type t_fourmi = {mutable dir : int;
mutable x : int;
mutable y : int};;

let trace_fourmi_deux_etats n =
let mouvement = [|(0, 5); (-5, 0); (0, -5); (5, 0)|] in
let init = open_graph " 800x800+50-50" in
let ma_fourmi = {dir = 0; x = 349; y = 349} in
let onestep () =
if (point_color ma_fourmi.x ma_fourmi.y) = white
then
begin
set_color black;
ma_fourmi.dir <-
if ma_fourmi.dir + 1 > 3 then 0 else ma_fourmi.dir + 1
end
else
begin
set_color white;
ma_fourmi.dir <-
if ma_fourmi.dir - 1 < 0 then 3 else ma_fourmi.dir - 1
end;
fill_rect ma_fourmi.x ma_fourmi.y 5 5;
let (dx, dy) = mouvement.(ma_fourmi.dir) in
ma_fourmi.x <- ma_fourmi.x + dx;
ma_fourmi.y <- ma_fourmi.y + dy;
in
init;
for i = 0 to n do
onestep ();
for j = 1 to 10000 do begin end done
done;;

trace_fourmi_deux_etats 10000;;

works perfectly in camllight (with a few modifications to adapt the code),
but not in Ocaml. The graphic window opens well, but the test

if (point_color ma_fourmi.x ma_fourmi.y) = white

is allways false under Ocaml.

Can you see the problem ?????

Thanks.

--

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

```

```next             reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-17  1:04 Nicolas FRANCOIS (AKA El Bofo) [this message]
2002-06-17 13:23 ` Jun P.FURUSE
2002-06-17 17:38   ` [Caml-list] Nicolas FRANCOIS (AKA El Bofo)
2002-06-18  9:48     ` [Caml-list] Re: Problem with Graph module Jun P.FURUSE
2002-06-18 16:53       ` Nicolas FRANCOIS (AKA El Bofo)
2002-06-18 23:13         ` Nicolas FRANCOIS (AKA El Bofo)
```

```Reply instructions:

You may reply publically 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,

Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

switches of git-send-email(1):

git send-email \
--to=nicolas.francois@free.fr \
--cc=caml-list@inria.fr \
```caml-list - the Caml user's mailing list