Start on lab 10
cd
cd cs101
mkdir lab10
cd lab10
Choose Language…
. In the left column, make sure the arrow head to the left of How to Design Programs
is pointing downwards. If the arrow is not pointing downwards, click on it. This will cause a list of language levels to appear. Click on Intermediate Student with lambda
. Select the OK button at the bottom right to save this selection.Now you are ready to begin our final lab! Remember that you will need to change the language on DrRacket on your own computer, too.
Your first lambda programs
build-list
and lambda
to define the following four functions that, respectively:(list 0 … (- n 1))
for any natural number n
; (list 1 … n)
for any natural number n
;(list 1 1/2 … 1/n)
for any natural number n
;n
even numbers;append
function in ISL concatenates the items of two lists or, equivalently, replaces '()
at the end of the first list with the second list:(check-expect (append (list 1 2 3) (list 4 5 6 7 8))
(list 1 2 3 4 5 6 7 8))
foldr
to define append-from-fold
.foldr
function is so powerful that you can define almost any list-processing functions with it. Use foldr
to define map-via-fold
, which simulates map
.You may have one week to finish this lab.
Submitting your work
You may have one week to finish this lab. Submit on Moodle when you are finished.
Log out
When you are done, remember to log out.