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] looping recursion
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@j...>
Subject: Re: [Caml-list] looping recursion
On Wednesday 28 July 2004 17:38, brogoff wrote:
> > brogoff wrote:
> > > Sometimes lists are best. If lists are OK for 100, 1_000, or 10_000
> > > items, why not 100_000 or 1_000_000? Map and friends shouldn't blow
> > > stack.

Creating an int list with 1,000,000 elements and applying using 
ocamlopt works fine here, and took a meagre 3.6 secs.

If you must use bytecode for this then just increase the stack size limit, for 
example to 8Mb:


Then it runs fine, in 10.7 secs here. Wow, that's quite fast... :-)

> Well, I'm still on the caml-list, so of course it isn't *that* bad. Also,
> as I said, if you need a tail recursive map over built in lists, you have
> at least two options. Unfortunately, my preference is to use Obj, which IMO
> points to a deficiency in the core language.

No! That points to a severe deficiency in your programming style. OCaml has 
been developed and used by a great many very clever people, and me. If you're 
doing things like that then you should immediately stop and think what you 
might be doing wrong. Perhaps you picked the bad style up at a Seattle OCaml 
user group meeting?

What's wrong with List.rev_map, List.rev (List.rev_map ...), increasing the 
size of the VM's stack, using native code or even writing your own, 
tail-recursive map?


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: