[Haskell-beginners] example of compostion

Ozgur Akgun ozgurakgun at gmail.com
Mon Jan 31 23:04:59 CET 2011


On 31 January 2011 21:15, Rainer Grimm <rainer at grimm-jaud.de> wrote:

> isTitle word=
>   isFirstUpperCase ( word) && isTailLowerCase ( word )
>   where isFirstUpperCase= isUpper . head
>     isTailLowerCase= all isLower . tail
>

One possible improvement is using pattern matching while defining isTitle.

isTitle []     = False -- I suppose?
isTitle (x:xs) = isUpper x && all isLower xs

-- 
Ozgur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110131/22056b24/attachment.htm>


More information about the Beginners mailing list