Material to Understand

Exercises

  1. Demonstrate a case where equal and eq return different results.
  2. Demonstrate a case where equal and = return different results.
  3. Use Clisp to determine whether 4 is an atom, a number, a symbol, and a list.
  4. Repeat question 3 for nil. Do you understand your results?
  5. Use Clisp to determine whether the numbers in '(2 3 4) are in ascending order.
  6. Explain the results of (not nil), (and (< 2 3) (evenp 6)), (or nil t nil), and (not '(1 2 3)).
  7. Write a function called compare that takes arguments a and b. The function should return the larger of the two values using an if statement.
  8. Write a function called compare-and-add that takes no arguments and uses a cond statement to compare the values stored in variables a and b. If a is larger, add one to the value of a and then return this value. If b is larger, add one to the value of b and then return this value. If they are equal, return the atom 'same. Test out your function to make sure that it is working properly.
  9. What happens if you try to use an if statement to solve question 8?
  10. Use the member function to show that '(cs425 starkey) is present in the list '((cs436 paxton)(cs425 starkey)(cs435 angryk)).
  11. (Problem 4-7.) Define check-temperature, a procedure that is to take one argument, such that it returns ridiculously-hot if the argument is greater than 100, ridiculously-cold if the argument is less than 0, and OK otherwise.