Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] @, List.append, and tail recursion
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-01-31 (09:40)
From: Olivier Andrieu <oandrieu@n...>
Subject: Re: [Caml-list] @, List.append, and tail recursion
 Brian Hurt [Thursday 30 January 2003] :
 > For short lists, this is the worst performer overall.  I whipped up a 
 > quick microbenchmark to compare the various implementations- the three 
 > implementations are included in this email.  The three programs are:
 > lappend uses the @ operator to append the list
 > uses local rev_append and rev functions (similiar to those in 
 > List) to append the list
 > uses Olivier's set_cdr function.
 > The results I saw (compiling with ocamlopt -o list on a 1.4GHz P4
 > running Linux and ocaml 3.06) are:
 > list1: 1.462s
 > list2: 1.757s
 > list3: 1.824s

There's an assert in setcdr : it's important because the first
argument mustn't be an empty list. It's never the case here, so you
can safely compile with -noassert.

On my hardware list3 seems to be a teeny bit faster than list1 but
anyway, since list2 is just barely slower, I'm not sure it's worth the

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: