Lecture overview -- Keyboard shortcut: 'u'  Previous page: Practical list construction -- Keyboard shortcut: 'p'  Next page: Association lists -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home    Lecture 2 - Page 21 : 46
Functional Programming in Scheme
Expressions, Types, and Functions
List functions

There exists a number of important List functions in Scheme, and we often write other such functions ourselves
We will here take a look at some of the most important list functions, as defined by the language itself. You are encouraged to read about them in the Scheme Report, to which we make a reference below.

  • (null? lst)     A predicate that returns whether lst is empty

  • (list? lst)     A predicate that returns whether lst is a proper list

  • (length lst)     Returns the number of elements in the proper list lst

  • (append lst1 lst2)     Concatenates the elements of two or more lists

  • (reverse lst)     Returns the elements in lst in reverse order

  • (list-ref lst k)     Accesses element number k of the list lst

It should be noticed that the first element is designated as element number 0. Thus (list-ref '(a b c) 1) returns b

  • (list-tail lst k)     Returns the k'th tail of the list lst