CSC 530 Assignment 0 -- Lisp Warm-Up Exercises
(Not for Credit)
-
Play around with the interpreter.
-
Implement Lisp's built-in length function using tail recursion. Note
that length is shallow in that it only counts the number of top-level elements,
without descending into sublists.
-
Implement a size function that computes the total number of atomic
elements in a list, including elements of nested sublists. This is the
structurally deep version of length.
-
Implement Lisp's union function that returns the set-based union of
two lists, i.e, an order-irrelevant merge of two lists with only a single copy
of duplicate elements. Assume that both inputs are sets, i.e., lists that do
not contain duplicate elements. Like length, union should
operate in a shallow fashion, merging only the top-level list elements without
descending into sublists. The equality test for duplicateness should use
equal as opposed to eq.
To get the idea of normal list processing in Lisp, all of the functions should
be recursive, non-destructive, not use prog, and be less than ten
lines each.