Expressions: self-assessment exercise

Fill in the empty boxes with the Lisp expressions described next to them.


Quoted expressions

The symbol whose name is fred

The result of evaluating the expression '1

The list containing the characters for alert and z

The list containing the list containing nil

Simple expressions

The identifier whose value is ()

The multiplication of the identifier a and 3

The application of the function foo to the string "ab" and the identifier z

The application of the function = to the numbers 3 and 4

Conditional expressions

Note that the function < performs a numerical less than test on its arguments.

The if expression which compares the numerical values of a and b returning either the string same or the string different

The if expression which compares the numerical values of a and b returning the smaller of the two

The cond expression which returns the symbols negative, zero or positive, depending on the corresponding value of the identifier x

Local declarations

The let expression that binds a to 1 and b to 2 and returns their sum

The let expression that binds a to b and b to a and returns the result of applying foo to them

The result of evaluating the above expression when a is 2, b is 3 and foo is +

The let* expression that binds a to b and b to a and returns the result of applying foo to them

The result of evaluating the above expression when a is 2, b is 3 and foo is +

Assignment and blocks

The assignment of the symbol nil to the identifier foo

The if expression which takes the values of a and b and if the result of (f a b) is true, does nothing, and if it is false, assigns b to a

The expression that exchanges the values of a and b


Press to clear the boxes or to display the answers


Julian Padget, jap@maths.bath.ac.uk, this version December 10, 1994