Sample Midterm
-
Code Description
-
-
What does the following code do?
-
-
(define (foo bar)
-
(list-ref bar (length bar))
-
-
-
Code Error Checking
-
-
Find all errors in this code
-
-
(define (sample function baz
-
(cond (baz > 10) (baz + 1)
-
(baz < 0 ) (0 - baz))
-
-
Code Fragments
-
Please do not write full functions here. Just one line of code will
usually
suffice
-
Check if a number is greater than 7
-
Write an if statement to do anything you like
-
Make a list of 3 elements. At least one of them should be a sublist
-
Return the second element of a list. Do not use list-ref
-
Check if there are elements in a list
-
-
-
Small Code
-
Write the following small functions
-
Check if a number is even or odd
-
Return the absolute value of a number
-
Return the last element of a list. Make sure to check that the input from
the user is a list. If it isn't, return an error message.
-
-
Thinking Problem
-
-
Compute the factorial of the sum of squares. Take a list as input, take
the sum of squares, and return the factorial of that number.
-
-
|