From: Mike Chen <mickey.chuen@gmail.com>
To: caml-list@inria.fr
Subject: While loop
Date: Mon, 30 Aug 2010 15:43:40 -0700 [thread overview]
Message-ID: <AANLkTimbYyvs64etwRB831q4g3aat5RD1_Rz1PjhGxXd@mail.gmail.com> (raw)
Hi,
I am a caml rookie, and I need your help.
(* pp is a very simple function *)
# let pp list =
let newList = ref [] in
let i = ref 0 in
let ele = ref (List.nth list !i) in
while (!ele) != 5 do
newList := List.append !newList [(!ele mod 3)];
i := !i + 1;
done;
!newList;;
val pp : int list -> int list = <fun>
# pp [ 3; 4; 5];;
(* it seems it goes into a forever loop, but I expect it returns [ 0;
1]. What is wrong? *)
Thanks,
Mike
next reply other threads:[~2010-08-30 22:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-30 22:43 Mike Chen [this message]
2010-08-30 22:53 ` TeXitoi
2010-08-30 22:57 ` [Caml-list] " Shawn Wagner
2010-08-30 23:25 ` Grant Olson
2010-08-30 23:49 ` TeXitoi
2010-08-31 0:17 ` [Caml-list] " Grant Olson
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=AANLkTimbYyvs64etwRB831q4g3aat5RD1_Rz1PjhGxXd@mail.gmail.com \
--to=mickey.chuen@gmail.com \
--cc=caml-list@inria.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