An expression can be replaced with a primitive:
Expression ::$\Rightarrow$ PrimitiveExpression
As with natural languages, primitives are the smallest units of meaning. Hence, the value of a primitive is its pre-defined meaning.
Scheme provides many different primitives. Three useful types of primitives are described next: numbers, Booleans, and primitive procedures.
Numbers. Numbers represent numerical values. Scheme provides all the kinds of numbers you are familiar with including whole numbers, negative numbers, decimals, and rational numbers.
Example numbers include:
Numbers evaluate to their value. For example, the value of the primitive
Booleans. Booleans represent truth values. There are two primitives for representing true and false:
PrimitiveExpression ::$\Rightarrow$ true | false
The meaning of |true| is true, and the meaning of |false| is false. In
the DrRacket interpreter,
\#f are used to represent the
primitive truth values. So, the value |true| appears as
\#t in the
|+||add||zero or more numbers||sum of the input numbers (
|*||multiply||zero or more numbers||product of the input numbers (
|-||subtract||two numbers||the value of the first number minus the value the second number|
|/||divide||two numbers||the value of the first number divided by the value of the second number|
|zero?||is zero?||one number||
|=||is equal to?||two numbers||
|<||is less than?||two numbers||
|>||is greater than?||two numbers||
|< =||is less than or equal to?||two numbers||
|> =||is greater than or equal to?||two numbers||
Table 3.1: Selected Scheme Primitive Procedures.
All of these primitive procedures operate on numbers. The first four are the basic arithmetic operators; the rest are comparison procedures. Some of these procedures are defined for more inputs than just the ones shown here (e.g., the subtract procedure also works on one number, producing its negation).
Primitive Procedures. Scheme provides primitive
procedures corresponding to many common functions. Mathematically, a
function is a mapping from inputs to outputs. For each valid input to
the function, there is exactly one associated output. For example,
is a procedure that takes zero or more inputs, each of which must be a
number. Its output is the sum of the values of the inputs. Table
3.1 describes some primitive
procedures for performing arithmetic and comparisons on numbers.