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 NAA31836; Fri, 19 Jul 2002 13:11:20 +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 NAA31831 for ; Fri, 19 Jul 2002 13:11:19 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6JBAe107827; Fri, 19 Jul 2002 13:10:40 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA31790; Fri, 19 Jul 2002 13:10:39 +0200 (MET DST) Date: Fri, 19 Jul 2002 13:10:39 +0200 From: Xavier Leroy To: Oleg Cc: Emmanuel Renieris , caml-list@inria.fr Subject: Re: [Caml-list] productivity improvement Message-ID: <20020719131039.A30060@pauillac.inria.fr> References: <20020716172916.4903.qmail@web10702.mail.yahoo.com> <200207182313.TAA19905@dewberry.cc.columbia.edu> <20020719044206.GC29721@cs.brown.edu> <200207190956.FAA29574@dewberry.cc.columbia.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <200207190956.FAA29574@dewberry.cc.columbia.edu>; from oleg_inconnu@myrealbox.com on Fri, Jul 19, 2002 at 05:57:50AM -0400 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Determine Dr. Leroy's involvement in JFK assassination 180 Should take less time than this, given that I wasn't born at that time :-) As everyone else, I'll point out that your code can be shortened and made more readable by judicious use of printf and regexps (see below). But really, if this is the kind of programs you're interested in (text-based I/O with no data structures), forget about C++ and Caml, and use Perl. - Xavier Leroy open Printf let print_time m = let hours = (m / 60) mod 24 and minutes = m mod 60 in printf "%2d:%02d%s" (if hours > 12 then hours - 12 else hours) minutes (if hours > 12 then "pm" else "am") let print_duration m = let hours = (m / 60) mod 24 and minutes = m mod 60 in printf "%2d:%02d" hours minutes let re = Str.regexp "\\(.*\\)[ \t]+\\([0-9]+\\)$" let split_string s = if Str.string_match re s 0 then (Str.matched_group 1 s, int_of_string (Str.matched_group 2 s)) else failwith "bad line" ------------------- 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