Version française
Home     About     Download     Resources     Contact us    
Browse thread
Correct way of programming a CGI script
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: William D. Neumann <wneumann@c...>
Subject: Re: [Caml-list] Correct way of programming a CGI script
On Tue, 09 Oct 2007 09:05:03 +1000, skaller wrote

> Fraid not. Python eats Ocaml alive.

Sure.  If you want to go about your task in a hideously naive manner.  Let's 
try something different:

# let time f a = let t0 = Unix.gettimeofday () in let r = f a in r,
(Unix.gettimeofday () -. t0);;
val time : ('a -> 'b) -> 'a -> 'b * float = <fun>

# let a_cat n = 
    let rec build_as acc = function 
    | 0 -> acc 
    | n -> build_as ("a"::acc) (pred n) 
    in String.concat "" (build_as [] n);;
val a_cat : int -> string = <fun>

# snd (time a_cat 1_000_000);;
- : float = 0.55100011825561523

Now, it's not necessarily the first ting a person might think of for this 
task, and it's not applicable to all uses of concatination, but for the task 
that started this thread (slapping together bits of text to make a web page) 
and for tasks like hard coding concatinations it's very convenient.

--

William D. Neumann