Functional Language Exercises
- Write a function that takes two parameters, an atom and a list,
and returns true if the atom is an element in the list and false
otherwise.
- Write a function that takes two parameters, a list
and an atom, and returns a list identical to the first parameter
except with all instances of the given atom deleted.
- Write a function similar to the previous one, except that it
deletes instances of a list (the second parameter) from a list of
lists (the first parameter). For example,
(deleteList '((1 2) (1 3) (1 2)) '(1 2))
would return '((1 3)).
- Write a function that takes two parameters, each of which is a
list of atoms, and returns a list similar to the first parameter
except that all atoms in the first list that are elements in the
second list have been removed from the first list. For example,
(removeAll '(1 2 1 3 4 2) '(1 2))
would return '(3 4).
- Write a function that takes a list as a parameter
and returns a list identical to the parameter
except the last element has been deleted.
- Write a function that returns the reverse of its simple list
parameter.
- Write a function that takes a list of numbers as a parameter and
returns a list with the smallest and largest numbers in the input
list.
For example, if you were to call the function on
'(1 2 3)
— or on
'(3 2 1)
— it would return
'(1 3)
.