[Haskell-cafe] Functions that return functions

michael rice nowgate at yahoo.com
Sun Apr 12 19:11:28 EDT 2009

You're getting ahead of me again.


--- On Sun, 4/12/09, Jake McArthur <jake.mcarthur at gmail.com> wrote:

From: Jake McArthur <jake.mcarthur at gmail.com>
Subject: Re: [Haskell-cafe] Functions that return functions
To: "michael rice" <nowgate at yahoo.com>
Cc: haskell-cafe at haskell.org
Date: Sunday, April 12, 2009, 5:45 PM

michael rice wrote:
> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090412/062157e6/attachment.htm

More information about the Haskell-Cafe mailing list