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 LAA30202; Fri, 19 Jul 2002 11:56:48 +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 LAA30198 for ; Fri, 19 Jul 2002 11:56:47 +0200 (MET DST) Received: from dewberry.cc.columbia.edu (dewberry.cc.columbia.edu [128.59.59.68]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6J9uk105271 for ; Fri, 19 Jul 2002 11:56:47 +0200 (MET DST) Received: from there (tw304h3.cpmc.columbia.edu [156.111.84.180]) by dewberry.cc.columbia.edu (8.9.3/8.9.3) with SMTP id FAA29574; Fri, 19 Jul 2002 05:56:45 -0400 (EDT) Message-Id: <200207190956.FAA29574@dewberry.cc.columbia.edu> Content-Type: text/plain; charset="iso-8859-1" From: Oleg To: Emmanuel Renieris Subject: Re: [Caml-list] productivity improvement Date: Fri, 19 Jul 2002 05:57:50 -0400 X-Mailer: KMail [version 1.3.2] Cc: caml-list@inria.fr References: <20020716172916.4903.qmail@web10702.mail.yahoo.com> <200207182313.TAA19905@dewberry.cc.columbia.edu> <20020719044206.GC29721@cs.brown.edu> In-Reply-To: <20020719044206.GC29721@cs.brown.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Friday 19 July 2002 12:42 am, Emmanuel Renieris wrote: > I see two ways to weed through this list: > Tell us what _you_ find hard/awkward/impossible in C++. Maybe somebody > will be able to point out how they are easier in Ocaml (if indeed they > are). The first thing that comes to mind: a program that would read, write, listen, look, speak, comprehend and pass the Turing test seems to be hard to create in C++. So hard, I've never tried[1] I'm not sure if it's the language though, although it could be. > Show us some of your ocaml code. Maybe there is some idiom you don't > have yet, and that would make a difference. Since this is the second time I'm asked, I will have to do that, even though the program is really straight-forward, silly and uninstructive. Description first, code at the end: Sometimes, when I feel like being organized and productive[2], which happens no more than thrice per fortnight, I plan things to do in advance and estimate time it will take me to do them: I edit a file containing a list of tasks and time in minutes, e.g. finish reading chapter 13 of ocaml book 30 Determine Dr. Leroy's involvement in JFK assassination 180 call dad 20 have supper 20 Go through T&R level in Halo in Legendary mode 30000 The program reads it from STDIN, calculates completion times and formats everything into a neat HTML table in STDOUT. I have a bash alias that glues VIM, this program and browser together, of course. Oleg [1] I'm not kidding. It really is hard. [2] And I actually am much more productive when I do that ------------------------------------------------------- let print_aux hours minutes = if hours < 10 then print_char ' '; print_int hours; print_char ':'; if minutes < 10 then print_char '0'; print_int minutes;; let print_time m = let m = m mod (60*24) in let hours = m / 60 in let hours = hours mod 24 in let hours = if hours > 12 then hours - 12 else hours in let tag = if m >= 12*60 then "pm" else "am" in let minutes = m mod 60 in print_aux hours minutes; print_string tag;; let print_duration m = let hours = m / 60 in let hours = hours mod 24 in let minutes = m mod 60 in print_aux hours minutes;; let curr_time = let tmp = Unix.localtime (Unix.time ()) in tmp.Unix.tm_min + 60 * tmp.Unix.tm_hour;; let isdigit = function '0' | '1' .. '9' -> true | _ -> false;; let split_string s = let i = ref (String.length s - 1) in while !i >= 0 && (s.[!i] = ' ' || s.[!i] = '\t') do i := !i-1 done; while (!i >= 0) && (isdigit (s.[!i])) do i := !i-1 done; i := !i+1; String.sub s 0 !i, int_of_string (String.sub s !i (String.length s - !i));; let print_table_entry name duration curr_time = print_string ("\t" ^ name ^ ""); print_duration duration; print_string ""; print_time (curr_time + duration); print_string "\n";; print_string " Schedule \n";; let rec read_and_print curr_time = let s = input_line stdin in let (s, v) = split_string s in print_table_entry s v curr_time; read_and_print (curr_time + v) in try read_and_print curr_time with _ -> ();; print_string "
\n";; ------------------- 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