User Tools

Site Tools


cs330_f2016:racketlists

This is an old revision of the document!


Objective:

Learn the basics of the Racket lists and various patterns of recursion:

  • List operators
  • Natural recursion
  • Common patterns for recursive list-processing operations
  • Using auxiliary variables

Preparation:

You will again use DrRacket, which you should have downloaded and installed for the previous lab.


Deliverables:

For this lab, you will need to implement the following functions and data structures in Racket:

  • check-temps1
  • check-temps
  • convert
  • duple
  • average
  • convertFC
  • eliminate-larger
  • get-nth
  • find-item

check-temps1

(define (check-temps1 temps) ...)

where tempsis a list of numbers representing temperatures and the value returned is a boolean indicating whether all of the temperatures are with the range 5 to 95 inclusive.

check-temps1

(define (check-temps temps low high) ...)

where tempsis a list of numbers representing temperatures and the value returned is a boolean indicating whether all of the temperatures are with the range low to high inclusive.

convert

(define (convert digits) ...)

where digits

duple

(define (duple lst) ...)

where lst

average

(define (average lst) ...)

where lst

convertFC

(define (convertFC temps) ...)

where temps

eliminate-larger

(define (eliminate-larger lst) ...)

where lst

get-nth

(define (get-nth lst n) ...)

where lst and n

find-item

(define (find-item lst target) ...)

where lst and target


Notes:

You again do not need to bulletproof the code to enforce proper inputs. Your code only needs to return correct values given correct inputs.


Hints:

You may want to again use Step button to walk through your code and watch the equivalent sequence of substitutions that are performed. This is particularly useful in tracing the recursion and watching what's happening to the parameters.

Again use check-expect to write your own unit tests for your code.

cs330_f2016/racketlists.1470847712.txt.gz · Last modified: 2021/06/30 23:40 (external edit)