1 Area
2 Vehicles
3 Students
4 Lists of Symbols
5 Lists of Numbers
Version: 4.1.1

Homework 2

Due Wednesday, October 14 by 3pm.

Language: Beginning Student

1 Area

Design a function that computes the area of a right angle triangle. The triangle should be specified by its three vertices, and each vertex should be of data type posn. The second vertex is the vertex of the right angle.

  ; area : posn posn posn -> number

  ; computes the area of a right angle triangle

2 Vehicles

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.

3 Students

Specify a student data type consisting of three fields: the name of the student, height (in feet) and weight (in kgs). Write a program that given an argument of type student returns a value of type student but after replacing the height in feet by height in inches and the weight in kgs by the weight in grams.

  ; conversion : student -> student

It accepts a student and returns the same student, but with converted height and weight measurements.

4 Lists of Symbols

Write a program that given a list of symbols, it determines if the list contains the symbol 'doll.

  ; 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) ---)

5 Lists of Numbers

Write the following functions: (The parameter alon stands for a list of numbers.)

  ; 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) ---)