Version: 4.1.1

## Homework 2

Language: Beginning Student

### 1Euclidian Distance

Design the function

 ; direct-to-0 : posn -> number ; determines how far a posn is from the origin, as the crow flies.

Design the function

; direct-between : posn posn -> number

that determines the distance between two points, as the crow flies.

Hint: wishlists & reuse!

### 2Vehicles

HtDP: 7.2.2. Make sure all vehicles have wheels

Develop the function

; toll : vehicle -> number

It determines the amount a vehicle must pay at a toll. The toll costs \$0.50 per wheel.

### 3Animals

Extend the animal data definition from class with one new kind of animal. Make sure the new animal has a weight.

Write a template for the extended animal data definition.

Write the function

; diet : animal -> animal

It accepts an animal and returns the same animal, but with half of the weight.

### 4Lists of Symbols

Write the following functions. Don’t forget about re-use and helper functions (the functions we wrote in class are fair game for re-use as helper functions).

 ; a list-of-symbols is either ; - empty, or ; - (cons symbol list-of-symbols) ; contains-doll? : list-of-symbols -> boolean ; to determine if 'doll appears in alos (define (contains-doll? alos) ---)

### 5Lists of Numbers

Write the following functions:

 ; a list-of-numbers is either ; - empty, or ; - (cons number list-of-numbers) ; len : list-of-numbers -> number ; to determine the number of elements in alon (define (len alon) ---) ; avg : list-of-numbers -> number ; to determine the average of the elements in alon (define (avg alon) ---) ; sq-nums : list-of-numbers -> list-of-numbers ; to square each element in alon (define (sq-nums alon) ---) ; rev : list-of-numbers -> list-of-numbers ; to reverse the elements in alon (define (rev alon) ---)