Chapter 3

Chapter 3 - Teach Yourself Scheme in Fixnum Days [Go to...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Teach Yourself Scheme in Fixnum Days [Go to first , previous , next page; contents ; index ] Chapter 3 Forms The reader will have noted that the Scheme example programs provided thus far are also s-expressions. This is true of all Scheme programs: Programs are data. Thus, the character datum #\c is a program, or a form . We will use the more general term form instead of program , so that we can deal with program fragments too. Scheme evaluates the form #\c to the value #\c , because #\c is self-evaluating. Not all s-expressions are self-evaluating. For instance the symbol s-expression xyz evaluates to the value held by the variable xyz . The list s-expression (string->number "16") evaluates to the number 16. Not all s-expressions are valid programs. If you typed the dotted-pair s-expression (1 . 2) at the Scheme listener, you will get an error. Scheme evaluates a list form by examining the first element, or head , of the form. If the head evaluates to a procedure, the rest of the form is evaluated to get the procedure's arguments, and the procedure is applied to the arguments. If the head of the form is a special form , the evaluation proceeds in a manner idiosyncratic to that form. Some special forms we have already seen are begin , define , and set! . begin causes its subforms to be evaluated in order, the result of the entire form being the result of the last subform. define introduces and initializes a variable.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

Chapter 3 - Teach Yourself Scheme in Fixnum Days [Go to...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online