[Haskell-beginners] print all days of calendar

kane96 at gmx.de kane96 at gmx.de
Fri Dec 18 11:01:01 EST 2009

I have to create a calendar like this:
type Calendar = [Date]

Date is:
type Day = Int
data Month = Jan | Feb | Mar | Apr | May | Jun | Jul | Ago | Sep | Oct | Nov | Dec deriving (Eq,Enum,Show)
type Year = Int
type Date = (Day,Month,Year)

I shall create a function: calendar :: Year -> Calendar that return a calendar for the given year like:
[(1, Jan, 2009), (2, Jan, 2009), ..., (31, Dec, 2009)]

I also have a function from a previous exercise which checks if a given date is valid. Is there a function for a loop that iterates from 1 to n and checks if the date is valid. If it's valid it should return the date otherwise it should jump to the next month or end at the end of the year? Or is it better to do it on another way with this data I have?

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