March 5, 1999

6.001 Recitation Notes

Brian Scassellati

Symbols and Quote

Scheme uses the character ' to distinguish between symbols and their values. The value of 'x is the symbol x and not the value of the thing named x.

The quote syntax 'expr is interpreted by the reader as syntactic sugar for (quote expr).

Practice giving the printed representation and the box-and-pointer diagram for each of the following:

Given the definitions above the line below, what does the Scheme interpreter print for each of the expressions below the line?

Symbol Equality

To determine if two numbers are identical, we use the Scheme primitive =. To determine if two symbols are identical, we use the Scheme primitive eq?. For example,

We will discuss other variations of eq? and other equality predicates next week, but remember that the behavior of eq? on numerical arguments is unspecified:

Building memq

(memq <item> <list>) will return return a sublist beginning with the first occurrence of the symbol <item>. If the symbol <item> is not contained in the <list>, then memq will return false.

What is the result of using memq in the following situations:

Puzzle

Can you write a scheme expression that prints itself?

(Hint: Consider how a cell reproduces. It contains its own blueprint (the DNA strand in the nucleus); reproduction involves (a) copying the blueprint, (b) implementing the blueprint. That is, it uses the blueprint twice.)

Administrivia

About this document ...

This document was generated using the LaTeX2HTML translator Version 95.1 (Fri Jan 20 1995) Copyright © 1993, 1994, Nikos Drakos, Computer Based Learning Unit, University of Leeds.

The command line arguments were:
latex2html -no_navigation -split 0 r10.tex.

The translation was initiated by Brian Scassellati on Fri Mar 5 17:44:06 EST 1999


Brian Scassellati
Fri Mar 5 17:44:06 EST 1999