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
Re: [Caml-list] queasiness about Exit
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Krishnaswami, Neel <neelk@c...>
Subject: Re: [Caml-list] queasiness about Exit
Andreas Rossberg [] wrote:
> For real mapping (as opposed to iteration) terminating early makes
> little sense. For iteration and folds it does. It is not too difficult
> to provide variations of iter and folds for your data structures that
> allow early breaks. For example, consider:
> BTW, this is one of the few problems where lazy evaluation 
> can play out its strengths: in a lazy language you do not need
> variations of iteration with early termination - you will always
> "terminate early" automatically.

I posted a similar question to comp.lang.functional a few months
ago, and Dan Wang showed me how I could use monads to make a
regular fold do that. 

I actually wanted to thread a state through a fold, but IIRC the 
technique will generalize to any monad (such as the exception
or continuation monad). Google reveals that the thread is at:

Neel Krishnaswami
Bug reports:  FAQ:
To unsubscribe, mail  Archives: