Posted: Tue Oct 21
Due: Wednesday 10/22 10:00am
Submission name: work14.rkt
Part 0
Copy the following code into the definitions pane of DrRacket and run it. You should run it multiple times. Then answer the questions below:
#lang racket
(define a (list 51 2 21 42 46 20))
(display "useful output for questions 1-4\n")
a
(first a)
(rest a)
(define b (rest a))
(first b)
(display "useful output for questions 5-6\n")
(build-list 5 sqrt)
(build-list 5 (lambda (x) (* x x)))
(display "useful output for questions 7-9\n")
(random)
(random 2)
(random 5 10)
Questions
Add a comment block #| ... |# and answer the following questions inside it.
- What does
firstdo? - What does
restdo? - For this question, write new code at the end of the provided code. Using the list
aas defined, how would you return the list starting at the number 21? - For this question, write new code at the end of the provided code. Using the list
aas defined, how would you return the number21? - What does
build-listdo? - For this question, write new code at the end of the provided code. Write a line of racket code that uses
build-listto create a list of the first 5 perfect cubes. - What does
randomdo if you give it no arguments? - What does
randomdo if you give it one argument? - What does
randomdo if you give it 2 arguments? - For this question, write new code at the end of the provided code. Write a line of racket code that uses
build-listandrandomto make a list of 10 random integers in the range [10, 20) (this includes 10 but excludes 20).