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
  1. Check if a number is greater than 7
  2. Write an if statement to do anything you like
  3. Make a list of 3 elements. At least one of them should be a sublist
  4. Return the second element of a list. Do not use list-ref
  5. Check if there are elements in a list
Small Code
Write the following small functions
  1. Check if a number is even or odd
  2. Return the absolute value of a number
  3. 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.