1 Exercises
2 Help Desk
3 Stepper
4 Sound

Lab 6

1 Exercises

HTDP/2e Exercises 20, 21.

2 Help Desk

In a DrRacket window, type string-length. Click to put the cursor on the word, then use F1 or right-click to open Help Desk, a browser-based system of documentation. There’s a lot of documentation there.

3 Stepper

Here’s a program:

;; returns true for strings shorter than
;; five chars
(define (short? str)
  (< (string-length str) 5))
 
;; truncates a string to the first four chars
;; unless it's already short
(define (maybe-truncate str)
  (cond [(short? str) str]
        [else (substring str 0 4)]))
 
(maybe-truncate "This is a long sentence.")
(maybe-truncate "Food")

Run this program in the stepper. Make sure that every step makes sense to you, and that you could reproduce these steps on a quiz.

4 Sound

Five functions to develop.

For these exercises, you’ll have to use the "Language defined in source" language level (in order for rsound-frames to work)