Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Why is (@) written in O'Caml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Oleg <oleg_inconnu@m...>
Subject: [Caml-list] Why is (@) written in O'Caml?
let rec (@) l1 l2 =
  match l1 with
    [] -> l2
  | hd :: tl -> hd :: (tl @ l2)

The O'Caml implementation of (@) is recursive and not tail-recursive. All one 
really has to do during "append" is copy l1 and set the last element's CDR to 
l2. I can see why this can not be done in O'Caml itself, but since (@) is 
such a common operation, I'm wondering why it was decided to implement it 
inefficently in O'Caml itself?

Cheers,
Oleg
-------------------
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