We use define
to assign values to variables.
For example, (define x 2)
assigns the value 2
to x
:
-> (define x 2)
-> x
2
-> (+ x 5)
7
After calling (define x 2)
, we say that x
is bound to 2
.
Variable bindings are stored in environments, which we'll talk more about in Unit 3.
(define pi 3.14159)
(define radius 3)
(define area (* radius radius pi))
(define circumference (* 2 pi radius))
What would area
evaluate to?
circumference
evaluate to?