Re: [Haskell-cafe] Functions that return functions

You're getting ahead of me again.
Michael
--- On Sun, 4/12/09, Jake McArthur
Admittedly, functions that return functions are Lispy, but perhaps there a Haskelly way to accomplish the same thing?
Actually, I think you will come to find that this way of thinking is more Haskelly than it is Lispy! import Control.Applicative ((<$), (<*>)) import Control.Arrow ((&&&)) import Control.Monad (guard) import Data.List (unfoldr) makeVerifier f m = (==0) . (`mod` m) . sum . zipWith f [1..] . unfoldr nextDigit where nextDigit = (<$) . (snd &&& fst) . (`divMod` 10) <*> guard . (/= 0) - Jake

michael rice wrote:
You're getting ahead of me again.
I'm sorry. I didn't expect you to understand the whole thing. Rather, I'm just showing what is possible. Notice that there is no lambda abstraction in the function implementation. The entire thing is constructed with combinators, functions that take other functions as arguments. I was trying to emphasize that it is very Haskelly to accept and return functions as happily as normal values. - Jake
participants (2)
-
Jake McArthur
-
michael rice