Re: [Haskell-cafe] Short-circuiting a fold

2007-04-05 Thread David House
On 05/04/07, Kurt Hutchinson [EMAIL PROTECTED] wrote: Straightforward: ssfold p f z = head . dropWhile ( not . p ) . scanl f z I'd prefer find instead of head . dropWhile (not . p), making the result type a Maybe, as this is essentially equivalent to searching through the result of a scan for

Re: [Haskell-cafe] Short-circuiting a fold

2007-04-05 Thread Stefan O'Rear
On Thu, Apr 05, 2007 at 02:09:12PM -0400, Kurt Hutchinson wrote: Here's a bit of Thursday afternoon fun. Mission: Define ssfold, a short-circuiting fold. It evaluates to the folded value that first satisfies the given predicate. ssfold :: ( a - Bool ) - ( a - b - a ) - a - [b] - a Here