On 31/01/07, David House [EMAIL PROTECTED] wrote:
dw :: (a - Bool) - [a] - [a]
dw p = reverse . fst . foldl comb ([],False)
where comb (xs,done) x | done = (x:xs, True)
| p x = (xs, False)
| otherwise = (x:xs, True)
I forgot to
Yet another higher order solution:
dropWhile' p0 xs = foldr f (const []) xs $ p0
where
f y ys p | p y = ys p
| otherwise = y : ys (const False)
Spencer Janssen
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
David House wrote:
It was a great article though, seeing
fix's definition in terms of foldr was one of those mind-bending
moments which makes learning Haskell what it is.
It's nice to see so many new solutions posted in the cafe.
The great thing about Haskell is that it keeps on giving :)
Dear all,
I pleased to announce that the latest issue of The Monad.Reader is
now available:
http://www.haskell.org/haskellwiki/The_Monad.Reader
Issue 6 consists of the following three articles:
* Bernie Pope - Getting a Fix from the Right Fold
* Dan Piponi - Adventures in Classical-Land
Wouter Swierstra [EMAIL PROTECTED] writes:
* Bernie Pope - Getting a Fix from the Right Fold
i ended up with this one:
dwBool predicate l = (foldr combine (\_ - []) l) True
where
combine e fl beg = if beg predicate e
then fl True
On 31/01/07, Pixel [EMAIL PROTECTED] wrote:
i ended up with this one:
dwBool predicate l = (foldr combine (\_ - []) l) True
where
combine e fl beg = if beg predicate e
then fl True
else e : fl False
Mine was:
dw :: (a - Bool) - [a]
dw :: (a - Bool) - [a] - [a]
dw p = reverse . fst . foldl comb ([],False)
where comb (xs,done) x | done = (x:xs, True)
| p x = (xs, False)
| otherwise = (x:xs, True)
Which is the simplest working algorithm I could come up with;