► |  | How to Design Programs Languages

1 | Beginning Student
2 | Beginning Student with List Abbreviations
3 | Intermediate Student
4 | Intermediate Student with Lambda
5 | Advanced Student
| Index

▼ | 1 | Beginning Student

1.1 | define
1.2 | define-struct
1.3 | Function Calls
1.4 | Primitive Calls
1.5 | cond
1.6 | if
1.7 | and
1.8 | or
1.9 | Test Cases
1.10 | empty
1.11 | Identifiers
1.12 | Symbols
1.13 | true and false
1.14 | require
1.15 | Primitive Operations

On this page:

define
lambda

Version: 4.1.4
top← prev up next →

#### 1.1`` define

(define (id id id ...) expr)

Defines a function. The first id inside the parentheses is the name of the function. All remaining ids are the names of the function’s arguments. The expr is the body of the function, evaluated whenever the function is called. The name of the function cannot be that of a primitive or another definition.

(define id expr)

Defines a constant id as a synonym for the value produced by expr. The defined name cannot be that of a primitive or another definition, and id itself must not appear in expr.

(define id (lambda (id id ...) expr))

An alternate form for defining functions. The first id is the name of the function. The ids in parentheses are the names of the function’s arguments, and the expr is the body of the function, which evaluated whenever the function is called. The name of the function cannot be that of a primitive or another definition.

lambda

The lambda keyword can only be used with define in the alternative function-definition syntax.

top← prev up next →