Problem Set 12h

home work!

Programming Language ISL+

This is the final problem set. You have until 7:00 PM, Wednesday December 3 to submit it.

These exercises are from How to Design Programs, First Edition

Problem 1: Exercise 32.2.1

Problem 2: Exercise 32.2.2

Problem 3: Exercise 32.2.3

Problem 4: Exercise 32.2.4

Problem 5: Exercise 32.2.5

Problem 6: Exercise 32.2.6

Problem 7: Exercise 32.2.7

Problem 8: Exercise 32.2.8

image

Problem 9

Extend the Husky language and the interpreter for it that we have developed in class to add the following features:
  1. Add the and and or boolean operators. Note that these are not primitive functions. Rather, they are new control operators (like cond): since they do short-circuit evaluation, they do not necessarily evaluate all of their parts.

    Here are the semantics for these two forms, in English:
    • (and exp1 exp2 ...) evaluates the exp expressions from left to right. As soon as some expression produces false, evaluation of the and form stops and the whole expression produces false. If all the exp expressions produce false, then the entire and produces true.

    • (or exp1 exp2 ...) evaluates the exp expressions from left to right. As soon as some expression produces true, evaluation of the or form stops and the whole expression produces true. If all the exp expressions produce false, then the entire or produces false.

  2. Add the primitive operations substring and string-append, so you can write programs in Husky that operate on strings.