Lab 13
This lab is due on Wednesday.
Follow the design recipe for each of these, including test cases. Test cases should be sufficient to exercise all of the code.
1 Using ’for’ in the Intermediate language
In order to allow you to use for/fold and similar functions in the Intermediate language, save this code in a file called "fors.rkt":
#lang racket (provide for/fold for/list in-range in-list)
Then, other racket files in the same directory can include this expression
(require "fors.rkt")
... to make these functions available in the Intermediate language.
Develop the sum-of-durations function, that accepts a list of sounds and returns the sums of their durations using a for/fold.
Develop (or copy) the sum function, that accepts a list of numbers and returns their sum.
Develop the durations function, that accepts a list of sounds and returns a list of their durations.
Develop the sum-of-durations-2 function, that behaves the same as sum-of-durations but is built by composing the prior two functions.
Develop the maybe-tone function, that accepts a midi note number and returns a tone of the given pitch of duration 1/4 second when the note number is between 60 and 70 (inclusive), and returns false otherwise. Develop test cases.
Develop the maybe-tones function, that accepts a list of midi note numbers and returns a sound containing the pitches returned by maybe-tone. Keep in mind that you’ll need to add only those elements that don’t return false.