[Haskell-beginners] find element of tupels

Magnus Therning magnus at therning.org
Fri Dec 18 14:09:11 EST 2009


On 18/12/09 14:57, kane96 at gmx.de wrote:
> thx Daniel. Now I implemented it like that to use my monthAndMaxDay list and just use the isLeapYear check for February:
> 
> legalDate :: Date -> Bool
> legalDate (myDay, Feb, myYear) = 0 < myDay && myDay <= (if isLeapYear        
>     myYear then 29 else 28)
> legalDate (myDay, myMonth, myYear) = maybe False id $ do
>     days <- lookup myMonth monthAndMaxDay
>     return (not (myDay <= 0) && (myDay <= days))

I know it's a minor detail, but wouldn't it be clearer to change that last
line to read something like this:

  return $ 0 < myDay && myDay <= days

?

/M

-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
Url : http://www.haskell.org/pipermail/beginners/attachments/20091218/1536c2ad/signature.bin


More information about the Beginners mailing list