Functions

A key concept in Scheme is that code is represented the same way as data and that data can be evaluated as code (this property is called homoiconicity, and is a large part of the language's expressive power). When a Scheme interpreter reads a list, it tries to interpret the first value in the list as a function call. For example,

   (list 1 2)
  

is interpreted as a call to the built-in function '(list)', which reads two or more atoms and returns a list. The function would return

(1 2)

as its evaluation.

With a handful of exceptions, all Scheme operations are performed in the form of a function call. For example, to add 2 to 3, you would write:

   (+ 2 3)
  

An extended equation would be written as nested calls:

   (/  (- 3  #i3.14)  (* (+ 1000 56) 5))
  

Since Scheme code is freeform, it can be written in a more readable manner like this:

   (/  (- 3  #i3.14) 
       (* (+ 1000 56)
             5))
  

Special Forms

Some of Scheme built-in primitives which, while resembling function calls, have slightly different behavior from an ordinary function. These functions are called special forms.

Contents Previous Next