12.7 Placement 4
On this page:
12.7.1 Goal
12.7.2 Language
12.7.3 Library
12.7.4 Reading
12.7.5 Task
12.7.6 Turnin

12.7 Placement 4

12.7.1 Goal

Functional programmers don’t actually spend all day writing recursive functions over lists. Rather, they use so-called “higher-order” functions, which are functions that consume other functions, to do that kind of work. That is, in functional programming, a loop is just a function, and different kinds of loops correspond to different kinds of higher-order functions. In this assignment you will learn about some of these “looping functions”.

12.7.2 Language

For the following assignment, you must use Racket’s Intermediate Student with lambda language. Go to the Language menu, select Choose Language, and pick the language from the Teaching Languages section.

12.7.3 Library

You will not need more than the following higher-order functions:
  • map

  • filter

  • foldl

  • foldr

  • andmap

  • ormap

You may also use any library function you were permitted to use on prior assignments, particularly in Placement 3.

12.7.4 Reading

You will read from Part 3 of HtDP 2/e, specifically
  • 14.1

  • 14.2

  • 14.4

  • 15.1

  • 15.4

  • 16.1

  • 16.2

  • 16.5

You can read the rest if you feel the need as you’re doing the assignment.

12.7.5 Task

Define the same functions as in Placement 3. However, you are not allowed to use explicit recursion; you must use one of the functions listed in Library in its stead. You are of course welcome to write helper functions.

You are welcome to reuse anything appropriate that you wish from your Placement 3 submission, e.g., purpose statements and tests. You do not need to write templates.

We do expect you to do a thorough job on testing, building on the feedback you received for Placement 3.

Note that unique is a bit challenging and it’s okay if you can’t complete it after you’ve spent a while trying.

12.7.6 Turnin

You will again turn in two files.

One file, named p4-code.rkt, contains the five functions required above (it can contain any other helper definitions you like as well). The functions must be named exactly as decribed and must take parameters exactly as described. (Note: Google Drive will automatically rename your file(s) to include your name. This is fine.)

In addition, following the instructions in the previous assignment, create and turn in a file of tests, p4-tests.rkt.

Failure to follow any of these instructions may result in zero credit.

Upload your files here. You will need to be logged into the Google@Brown domain to upload.