This shows you the differences between two versions of the page.
cs330_f2016:racketlists [2016/08/10 16:39] morse [Hints:] |
cs330_f2016:racketlists [2021/06/30 23:42] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====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 === | ||
- | <code racket> | ||
- | (define (check-temps1 temps) ...) | ||
- | </code> | ||
- | where ''temps''is 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 === | ||
- | <code racket> | ||
- | (define (check-temps temps low high) ...) | ||
- | </code> | ||
- | where ''temps''is 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 === | ||
- | <code racket> | ||
- | (define (convert digits) ...) | ||
- | </code> | ||
- | where ''digits'' ... | ||
- | |||
- | === duple === | ||
- | <code racket> | ||
- | (define (duple lst) ...) | ||
- | </code> | ||
- | where ''lst'' ... | ||
- | |||
- | === average === | ||
- | <code racket> | ||
- | (define (average lst) ...) | ||
- | </code> | ||
- | where ''lst'' ... | ||
- | |||
- | === convertFC === | ||
- | <code racket> | ||
- | (define (convertFC temps) ...) | ||
- | </code> | ||
- | where ''temps'' ... | ||
- | |||
- | === eliminate-larger === | ||
- | <code racket> | ||
- | (define (eliminate-larger lst) ...) | ||
- | </code> | ||
- | where ''lst'' ... | ||
- | |||
- | === get-nth === | ||
- | <code racket> | ||
- | (define (get-nth lst n) ...) | ||
- | </code> | ||
- | where ''lst'' and ''n'' ... | ||
- | |||
- | === find-item === | ||
- | <code racket> | ||
- | (define (find-item lst target) ...) | ||
- | </code> | ||
- | 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. |