Page 1 of 1

Problem with a Programm

Posted: Tue Nov 04, 2014 10:29 am
by ronnyempire
Hello, im learning scheme now for one week. And i have a Problem with one programm. I have to create a programme, which validate a given date witout year and give bach true or false.
So for example (valid-date? 31 4) has to return #f
The condition is no years and the feb always has 28 days. Ive tried the hole night with the function cond equal but no idea how it can be work.
Does anyone have ideas please ?

thank you

Re: Problem with a Programm

Posted: Wed Nov 05, 2014 6:33 pm
by logxor
I don't know Scheme but I'm guessing COND works the same way as in CL. You can test the month number with COND and, within the matching clause, validate the day number like so:

Code: Select all

(cond ((= month 1) (<= day 31))
      ((= month 2) (<= day 28))
      ((= month 3) (<= day 31))
      ...)
And, of course, return false if the month number is out of range.