English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Stack Overflow... (recursion in try-statement)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-04-24 (13:35)
From: Oliver Bandel <oliver@f...>
Subject: Re: [Caml-list] Stack Overflow... (recursion in try-statement)

On Wed, 24 Apr 2002, Alan Schmitt wrote:

> let rec traversedir dir =
>   try 
>     let d = Unix.readdir dir in
>     d :: (traversedir dir)
>   with
>   | End_of_file -> []
> (Disclaimer: I didn't test the code). The idea is you force the
> evaluation of readdir before the recursive call.
> I also modified the [d] @ l into a d :: l, which seems to be the same
> thing to me.

Yes, I (should have) looked for "::" but used "@".

I think it's not only "the same" (it's not the same,
but the result is the same ;-)), but it's the better

Yes, I have to use "::", because I only want to add *one element*
to a list and do not really want to  concatenate two lists.


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