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
Problem with a Programm
Forum rules
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.
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:
And, of course, return false if the month number is out of range.
Code: Select all
(cond ((= month 1) (<= day 31))
((= month 2) (<= day 28))
((= month 3) (<= day 31))
...)