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] Probably FAQ: Why is list-append (list :: elem) so expensive?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-09-25 (15:39)
From: Noel Welsh <noelwelsh@y...>
Subject: Re: [Caml-list] Probably FAQ: Why is list-append (list :: elem) so expensive?
O'Caml's heritage is from the functional world, so
side-effects are discouraged.  Maintaining a tail
pointer requires side-effects.  

For more insight consider that a list is defined by
its recursive definition:

List 'a :=  Cons 'a * List
        |   Null

A list is a cons cell containing an element and the
rest of the list, or null, which terminates the list. 
Now tell me which cons cell is the head, and so should
maintain the tail pointer. Welcome to a world of pain!


Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: