Exercises in this lecture              Go to the slide, where this exercise belongs -- Keyboard shortcut: 'u'  

Exercise 1.3
A Proper List Predicate *


The Scheme function (predicate) pair? tells if its parameter is a pair (constructed by cons). The function null? tells if its parameter is the empty list. The function list? tells if its parameter is a proper list. In this exercise, write your own version of list?

Intuitively, a proper list is empty, or it is 'ended by' an empty list (by following the cdr chain).

You may want to read about pairs and lists in the Scheme Report.

Can you write your predicate without thinking (and programming) in terms of a while loop?

Can you write your predicate without using if or cond?

Please - consider carefully all these questions!


Solution