caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* While loop
@ 2010-08-30 22:43 Mike Chen
  2010-08-30 22:53 ` TeXitoi
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Mike Chen @ 2010-08-30 22:43 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-08-31  0:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-30 22:43 While loop Mike Chen
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).