Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] looping recursion
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Hurt <bhurt@s...>
Subject: Re: [Caml-list] looping recursion
On Tue, 27 Jul 2004 briand@aracnet.com wrote:

> That's just not good !  I can't even use standard map without the
> stack blowing up ?  This is a Bad Thing (TM).

Take a look at ExtLib:
http://sourceforge.net/projects/ocaml-lib/

This contains a drop-in compatible replacement to the List library, which 
includes a List.map function that doesn't blow up.

If your list is that long, I'd actually recommend doing one of two things:

1) Switch off your list data structure for a more complicated data 
structure, like a Set.  If you do any sort of complicated access 
patterns, this will likely be a big win, or

2) If you only ever need to iterate through the list (and thus have simple 
access requirements), consider switching over to using an ExtLib style 
enum (same basic concept as Java's Iterator class).  This allows you do 
"wavefront" processing- apply the map to the list items as you read them 
in.

Very long lists are a sign that you're using the wrong data structure.

-- 
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 
Brian

-------------------
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