This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Problem with a Programm

2 posts · 4881 views

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

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:
(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.