« What would Gandhi Really Do? | Main | Another DSL embedded in Haskell - a partial make replacement in less than 10 lines »

June 04, 2007


handelspand te koop

This is fabulous report. I loved to see your blog with great presentation.


how define isDayOfWeek


Joachim: Noooo! Don't say that! That's what they said about the year 2000...


Nice, but I'm not sure it's as DSLish as, say, Ruby's



Your formula for the number of days in February is not quite right: if the year number is divisible by 100 and not 400, it is not a leap year. So 2000 was a leap year, but 1900 wasn't. You need to replace:

if y `mod` 4 == 0


if y `mod` 4 == 0 && (y `mod` 100 /= 0 || y `mod` 400 == 0)

Stelios Sfakianakis

A minor correction: the definition of the leap years should take into account the century years e.g. 1900 was not a leap year. Something like

y `mod` 4 == 0 && y `mod` 100 /=0 
|| y `mod` 400 ==0
will be ok.

cheers, stelios

Joachim Breitner

Just a minor note: Your leap year code is not correct, as every 100th, but not 400th, year is not a leap year. Maybe something like

> if (y `mod` 4 == 0 and y `mod` 100 /= 0) || y `mod` 400 == 0 then 29 else 28

Not that it really matters if the code is wrong in 2100, I guess :-)

The comments to this entry are closed.


Tip Jar

  • Amazon Honor System Click Here to Pay Learn More
Blog powered by Typepad

Twitter Updates

    follow me on Twitter