Midterm Exam for CS105-Fall 1997

Warming Up

Conditionals

Write a function season that tells you what season you are in on a given date (specified by month and day). Assume the following fixed dates for the seasons:
Spring: 3/21 - 6/20
Summer: 6/21 - 9/20
Autumn: 9/21 - 12/20
Winter: 12/21 - 3/20.
For example (season 6 21) => Summer and (season 10 27) => Autumn

Higher-order functions and lambda

Recursion in arithmetic

Recursion on words

Write a function prefix that takes as input an integer and a word and returns as many letters starting from the beginning of the word as the integer indicates. For example (prefix 3 'Arthur) => art and (prefix 0 'Arthur) => "". You may assume that the integer is at most the length of the word.