6.11.0.4

Week 9 Set a

home work!

Programming Language ISL+

Due Date Mon at 9:00pm (Week 9)

Purpose to practice the design of functions that consume two non-atomic forms of data

Finger Exercises

Exercise 1 Design a function that can follow a path of directions into a binary tree. Here are the relevant data definitions:
; A Path is one of:
;  'left
;  'right
; 
(define-struct node [left right])
; A BTree is one of:
;  Number
;  (make-node BTree Btree)
The function signals an error if the given path goes too deep into the BTree. Otherwise it produces the subtree at the end of the Path.

Exercise 2 From HtDP, 389 and 395.

Graded Exercises

Exercise 3 The software architect of ApperGamersoftware has come up with yet another way of making the game more interesting.

Instead of a single piece of food, the game will supply a bunch of food. Every time one of the gobblers (the player’s or any of the AI gobblers) gets close enough, it eats the food. At each round, the player’s gobbler has priority over the AI gobblers. If a gobbler is close enough to two pieces of food, it may gorge on both. Once a piece of food is eaten, no other gobbler gets to eat the food.

Your software architect has identified the essential change to the data representation:
; Gobble is (make-gobble N [Listof Turkey] Turkey [Listof Food])
; interpretation The gobblers now compete for several pieces of
; food, not just one.

Your first task is to adjust all test cases so that they deal with a list of one piece of food instead of a single piece.

Your next task is to design a pair of functions that implement the essence of the "feeding step".

The first one is eat*. It consumes a list of gobblers and a list of food. Each piece of food that is close enough to a gobbler is eaten. The function produces a list of fattened turkeys.

The second one is was-eaten*, which consumes a list of gobblers and a list of food. Each piece of food that could be eaten is removed from the latter. The result is a "cleansed" list of food.

Note You still have failing test cases for all the other functions.