[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lists



The R4RS has a section that carefully describes a "list" as something
that has finite length and ends in nil, ie., a proper list.

member is specified as taking a list for its second argument, so
the usual definition:

  (define member
    (lambda (x l)
      (cond [(null? l) #f]
            [(equal? x (car l)) l]
            [else (member x (cdr l))])))

is too liberal, since (member 'a '(a . 5)) works.

The R4RS also specifies list-tail to take a list as its first argument,
and says explicitly that list-tail could be defined by:

  (define list-tail
    (lambda (x k)
      (if (zero? k)
          x
          (list-tail (cdr x) (- k 1)))))

This definition is also too liberal.

What is the intended interpretation of "list" as an argument type
specification for the various library functions?  My guess is that
an interpretation may provide the restrictive implementation, but is
free to provide the more liberal version.  If so, this should be said
explicitly.  The description of list-tail should also be fixed.

Andrew