From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA08141; Thu, 15 Nov 2001 18:29:01 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA08532 for ; Thu, 15 Nov 2001 18:29:00 +0100 (MET) Received: from smtp2.cswv.com (smtp2.cswv.com [4.17.129.20]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id fAFHSxH17856 for ; Thu, 15 Nov 2001 18:29:00 +0100 (MET) Received: from exchange1.cswv.com ([10.2.3.9]) by smtp2.cswv.com with Microsoft SMTPSVC(5.5.1877.197.19); Thu, 15 Nov 2001 12:28:53 -0500 Received: by exchange1.cswv.com with Internet Mail Service (5.5.2653.19) id ; Thu, 15 Nov 2001 12:33:12 -0500 Message-ID: From: "Krishnaswami, Neel" To: caml-list@inria.fr Subject: Re: [Caml-list] queasiness about Exit Date: Thu, 15 Nov 2001 12:33:02 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Andreas Rossberg [mailto:rossberg@ps.uni-sb.de] 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: http://groups.google.com/groups?threadm=slrn9ig78d.gpl.neelk%40brick.cswv.co m -- Neel Krishnaswami neelk@cswcasa.com ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr