Due: Thursday 10/10 10:00am

Submission name: work13.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:

(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.

  1. What does first do?
  2. What does rest do?
  3. For this question, write new code at the end of the provided code. Using the list a as defined, how would you return the list starting at the number 21?
  4. For this question, write new code at the end of the provided code. Using the list a as defined, how would you return the number 21?
  5. What does build-list do?
  6. For this question, write new code at the end of the provided code. Write a line of racket code that uses build-list to create a list of the first 5 perfect cubes.
  7. What does random do if you give it no arguments?
  8. What does random do if you give it one argument?
  9. What does random do if you give it 2 arguments?
  10. For this question, write new code at the end of the provided code. Write a line of racket code that uses build-list and random to make a list of 10 random integers in the range [10, 20) (this includes 10 but excludes 20).