This is a simplification -- there are other kinds of data in Scheme -- but we can get a lot of mileage out of lists and atoms.
So:
A list is eitherThe empty list may be written as null, or '(). Why do we need the empty list in this definition?
the empty list, or
the cons of a Scheme value onto a list
Here are some examples of Scheme expressions that yield lists:
null (cons 'a null) (cons "a" null) (cons 'a (cons 'b null)) (cons 'com1340 (cons 42 null)) (cons 'foo (cons 'bar (cons 'baz null))) (cons (cons 'foo null) (cons 'bar (cons 'baz null)))
Observe: cons takes two arguments, never more, never fewer. Observe also: we had to use null in each of these examples. Observe further: the length of a list is the same as the number of top-level conses used to create it.
Writing out all those conses is tiresome. Scheme provides a more concise way to specify lists, using the list primitive. Here are the same examples, redone:
(list) (list 'a) (list "a") (list 'a 'b) (list 'com1340 42) (list 'foo 'bar 'baz) (list (list 'foo) 'bar 'baz)
Observe: the arity of list is not fixed. It accepts an arbitrary number of arguments. Observe also: we did not have to write null anywhere. But the empty list is always implicitly contained in the results!
What does DrScheme print out when these lists are evaluated?