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 FAA14053; Sat, 21 Apr 2001 05:20:04 +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 FAA14067 for ; Sat, 21 Apr 2001 05:20:03 +0200 (MET DST) Received: from mailout05.sul.t-online.com (mailout05.sul.t-online.com [194.25.134.82]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f3L3K2506046 for ; Sat, 21 Apr 2001 05:20:02 +0200 (MET DST) Received: from fwd05.sul.t-online.com by mailout05.sul.t-online.com with smtp id 14qnwI-00036l-00; Sat, 21 Apr 2001 05:20:02 +0200 Received: from pD901A161.dip.t-dialin.net (340009195196-0001@[217.1.161.97]) by fwd05.sul.t-online.com with esmtp id 14qnwI-03tz2OC; Sat, 21 Apr 2001 05:20:02 +0200 Date: Sat, 21 Apr 2001 05:25:34 +0200 (CEST) From: markus.kliegl@t-online.de (markus.kliegl) To: Caml List Subject: [Caml-list] Random results Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Sender: 340009195196-0001@t-dialin.net Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, Sorry for the length of the message. I have the following program: let rot = ref false;; let rot13_char c = let x = int_of_char c in if (x >= 65 && x < 78) || (x >= 97 && x < 110) then char_of_int (x + 13) else if (x >= 78 && x < 91) || (x >= 110 && x < 123) then char_of_int (x - 13) else c ;; let rot13_str str = for i = 0 to String.length str - 1 do str.[i] <- (rot13_char str.[i]) done; str ;; let rot_print str = if !rot = false then print_endline str else print_endline (rot13_str str) ;; let rec beer n = if n = 1 then begin rot_print "1 bottle of beer on the wall"; rot_print "1 bottle of beer"; rot_print "Take one down and pass it around"; rot_print "No bottles of beer on the wall" end else begin print_int n; rot_print " bottles of beer on the wall"; print_int n; rot_print " bottles of beer"; rot_print "Take one down and pass it around"; print_int (n - 1); rot_print " bottles of beer on the wall"; print_newline (); beer (n - 1) end ;; let main argc argv = if (argc > 1) && (argv.(1) = "rot13") then rot := true; beer 99 ;; main (Array.length Sys.argv) Sys.argv When running it without the optional argument 'rot13', the output is correct. However, when I do run it with that argument, I get results in which some lines are rot13-ed and others not, e.g.: 3 obggyrf bs orre ba gur jnyy 3 obggyrf bs orre Gnxr bar qbja naq cnff vg nebhaq 2 obggyrf bs orre ba gur jnyy 2 bottles of beer on the wall 2 bottles of beer Take one down and pass it around 1 bottles of beer on the wall 1 obggyr bs orre ba gur jnyy 1 obggyr bs orre Gnxr bar qbja naq cnff vg nebhaq Ab obggyrf bs orre ba gur jnyy I'm using Ocaml 3.00, by the way. Is this a bug in my program (I can't find it) or in Ocaml? Thanks, Markus Kliegl ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr