# 3.4.1 Primitives

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:

150 | 0 | -12 |

3.14159 | 3/4 | 999999999999999999999 |

Numbers evaluate to their value. For example, the value of the primitive
expression `1120`

is `1120`

.

**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, `\#t`

and `\#f`

are used to represent the
primitive truth values. So, the value |true| appears as `\#t`

in the
interactions window.

Symbol |
Description |
Inputs |
Output |
---|---|---|---|

+ | add | zero or more numbers | sum of the input numbers (`0` if there are no inputs) |

* | multiply | zero or more numbers | product of the input numbers (`1` if there are no inputs) |

- | 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 | `true` if the input value is `0` , otherwise `false` |

= | is equal to? | two numbers | `true` if the input values have the same value, otherwise `false` |

< | is less than? | two numbers | `true` if the first input value has lesser value than the second input value, otherwise `false` |

> | is greater than? | two numbers | `true` if the first input value has greater value than the second input value, otherwise `false` |

< = | is less than or equal to? | two numbers | `true` if the first input value is not greater than the second input value, otherwise `false` |

> = | is greater than or equal to? | two numbers | `true` if the first input value is not less than the second input value, otherwise `false` |

**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.