Composing Music with Computers

Appendix 4: A Primer in Lisp Programming

Lisp presents itself to the user as an interpreter; it works both as a programming language and as an interactive system: it waits for some input or command from the user, executes it, and waits again for further input. Lisp is an acronym for List Processor; almost everything in the Lisp world is a list. In programming terms, a list is a set of elements enclosed between parentheses, separated by spaces. The elements of a list can be numbers, symbols, other lists, and indeed, programs. Examples of lists are:

 (the number of the beast) (1 2 3 5 8 13) (0.666 (21 xyz) abc) (defun plus (a b) (+ a b))

Lisp is excellent at manipulating lists; there are functions that can do almost any operation you can possibly imagine with lists. Programs are lists themselves and they have the same simple syntax of lists. The following example illustrates what happens if one types in a short program for the Lisp interpreter. The sign > is the command line prompt indicating that the interpreter is waiting for your command (this prompt may vary from implementation to implementation):

 > (+ 330 336) 666

When the interpreter computes (or evaluates, in Lisp jargon) a list, it always assumes that the first element of the list is the name of a function and the rest of the elements are the arguments that the function needs for processing. In the above example, the interpreter performs the addition of two numbers; the...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Communications Software
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.