[Haskell-beginners] find element of tupels

kane96 at gmx.de kane96 at gmx.de
Fri Dec 18 09:35:52 EST 2009


-------- Original-Nachricht --------
> Datum: Thu, 17 Dec 2009 20:44:34 +0100
> Von: "Henk-Jan van Tuyl" <hjgtuyl at chello.nl>
> An: kane96 at gmx.de, beginners at haskell.org
> Betreff: Re: [Haskell-beginners] find element of tupels

> On Thu, 17 Dec 2009 17:18:41 +0100, <kane96 at gmx.de> wrote:
> 
> > thanks Magnus, great, works so far. I added to check that myDay have to 
> > be greater 0:
> >
> > legalDate :: Date -> Bool
> > legalDate (myDay, myMonth, myYear) = maybe False id $ do
> >     days <- lookup myMonth monthAndMaxDay
> >     return (not (myDay <= 0) && (myDay <= days))
> >
> > Another thing is, that I have to check for leapYears. I have a function 
> > that checks if a year is a leap year
> >
> > isLeapYear :: Int -> Bool
> > isLeapYear year = mod year 4 == 0
> 
> That is not entirely correct; from package time:
>    isLeapYear :: Integer -> Bool
>    isLeapYear year = (mod year 4 == 0) && ((mod year 400 == 0) || not (mod
>  
> year 100 == 0))

ok


> 
> 
> >
> > monthAndMaxDay has 30 days for February which have to be fix. So i have 
> > to check in legalDate if the year is a leap year. If so I have to check 
> > myDay in February for 29 days, otherwise for 28 days. How can I  
> > implement this to isLegalDate?
> 
> Use fromGregorianValid from package time.

but the problem is I shall implement it on my own in this exercise


> 
> Regards,
> Henk-Jan van Tuyl
> 
> 
> --
> http://Van.Tuyl.eu/
> http://members.chello.nl/hjgtuyl/tourdemonad.html
> --
> 
> 
> 
> -- 

-- 
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/chbrowser


More information about the Beginners mailing list