Lists

A very common Scheme data structure is the list. Formally, a ‘proper’ list is defined to be either the empty list with its input form '() and length 0, or a pair whose cdr in turn is a shorter list.

There are many ways of creating lists. Perhaps the most common is with the list procedure:

guile> (list 1 2 3 "abc" 17.5)
(1 2 3 "abc" 17.5)

Representing a list as individual elements separated by whitespace and enclosed in parentheses is actually a compacted rendition of the actual dotted pairs constituting the list, where the dot and an immediately following starting paren are removed along with the matching closing paren. Without this compaction, the output would have been

(1 . (2 . (3 . ("abc" . (17.5 . ())))))

As with the output, a list can also be entered (after adding a quote to avoid interpretation as a function call) as a literal list by enclosing its elements in parentheses:

guile> '(17 23 "foo" "bar" "bazzle")
(17 23 "foo" "bar" "bazzle")

Lists are a central part of Scheme. In, fact, Scheme is considered a dialect of lisp, where ‘lisp’ is an abbreviation for ‘List Processing’. Scheme expressions are all lists.


Extending LilyPond v2.25.22 (development-branch).