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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: james woodyatt <jhw@w...>
Subject: Re: [Caml-list] About Obj (was Recursive lists)
On 11 Oct 2004, at 06:38, Christophe Raffalli wrote:
> Jean-Christophe Filliatre wrote [quite sensibly]:
>>
>> [...]
>> This shouldn't be advised, and not even posted on this list.
>
> And how do you write a tail recursive map doing only one structure 
> traversal (which is important with the penalty for memory access) on 
> immutable list without the Obj module ?

By using a more appropriate data structure, e.g. a lazy list.  It's a 
pay-me-now-or-pay-me-later sort of game you're playing here.

Rather than whack on the immutable list, maybe you should consider 
doing this:

	type 'a mlist = N | C of 'a mcell
	and 'a mcell = { mutable cdr: 'a; mutable car: 'a mlist }

No need to thank me.


-- 
j h woodyatt <jhw@wetware.com>
markets are only free to the people who own them.

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