Lennart Augustsson wrote:
Sure, but we also have
para f e xs = snd $ foldr (\ x ~(xs, y) -> (x:xs, f x xs y)) ([], e) xs
Nice one.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Sure, but we also have
para f e xs = snd $ foldr (\ x ~(xs, y) -> (x:xs, f x xs y)) ([], e) xs
So I think using para is fine.
-- Lennart
On Feb 12, 2007, at 18:40 , Bernie Pope wrote:
Nicolas Frisby wrote:
Guess this is a tricky choice for a foldr intro, since it requires a
"paramor
Oops; I totally forgot the context of this whole discussion!
I enjoyed your article.
On 2/12/07, Bernie Pope <[EMAIL PROTECTED]> wrote:
Nicolas Frisby wrote:
> Guess this is a tricky choice for a foldr intro, since it requires a
> "paramorphism" (see bananas lenses wires etc.)
>
> para :: (a ->
Nicolas Frisby wrote:
Guess this is a tricky choice for a foldr intro, since it requires a
"paramorphism" (see bananas lenses wires etc.)
para :: (a -> [a] -> b -> b) -> b -> [a] -> b
para f e [] = e
para f e (x:xs) = f x xs (para f e xs)
-- note that the original tail of the list (i.e. xs and
Guess this is a tricky choice for a foldr intro, since it requires a
"paramorphism" (see bananas lenses wires etc.)
para :: (a -> [a] -> b -> b) -> b -> [a] -> b
para f e [] = e
para f e (x:xs) = f x xs (para f e xs)
-- note that the original tail of the list (i.e. xs and not xs') is
used in the
pixel:
> Chris Moline <[EMAIL PROTECTED]> writes:
>
> > dropWhile p = foldr (\x l' -> if p x then l' else x:l') []
>
> invalid: dropWhile (< 5) [1, 10, 1] should return [10, 1]
Prelude Test.QuickCheck Text.Show.Functions> quickCheck $ \p xs -> dropWhile p
xs == foldr (\x l' -> if p x then l'
Chris Moline <[EMAIL PROTECTED]> writes:
> dropWhile p = foldr (\x l' -> if p x then l' else x:l') []
invalid: dropWhile (< 5) [1, 10, 1] should return [10, 1]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listi
I hope the following doesn't come across as
condescending...
The recent issue of The Monad Reader has generated
some excitement, mostly to do with the time travel
article. I, however, would like to discuss a simpler
solution to implementing dropWhile with foldr, which
is discussed in the first art