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

June 04, 2007

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d8341e003353ef00e5508698b98834

Listed below are links to weblogs that reference Haskell, DSL and Monad:

Comments

handelspand te koop

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

123

how define isDayOfWeek

Miles

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

Miles

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

20.minutes.ago
:-)

Pete

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

with

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.

Ads




Tip Jar



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

Twitter Updates

    follow me on Twitter