Solutions to selected exercises, Foundations of Computing, Fall 2000

Here are some exercise solutions we discussed in class.


Exercise 8.14, page 125 in Simply Scheme

Write a procedure subword that takes three arguments: a word, a starting position, and an ending position number. It should return the subword containing only the letters between the specified positions:

> (subword 'polythene 5 8)
THEN
(define (subword wd m n)
  (let ((mm (- m 1))
        (kn (- (count wd) n)))
    ((repeated bl kn)
     ((repeated bf mm) wd))))

Jon Jacky, jackyj@evergreen.edu