foldl :: (a -> b -> a) -> a -> [b] -> a
foldl f a bs =
foldr (\b g x -> g (f x b)) id bs a
But I need a consistent approach.
Dimitri DeFigueiredo <defigueiredo@ucdavis.edu> writes:
Here's a simple exercise from Stephanie Weirich's class [1] that I am having
a hard time with.
consider
doTwice :: (a -> a) -> a -> a
doTwice f x = f (f x)
what does this do?
ex1 :: (a -> a) -> a -> a
ex1 = doTwice doTwice
Another way to write doTwice is:
doTwice :: (a -> a) -> (a -> a)
doTwice f = \x -> f (f x)
This is equivalent. If you stare it for a while, it should answer the rest of
your questions.
John
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners