Scheme is always attempting to discover the value of an expression:
| Expression | Value |
| 5 | 5 |
| "hello" | "hello" |
| * | function |
| () | () |
| x | undefined |
You can bind values of expressions to symbols using define. They key here is "the values of expressions". In otherwords, scheme will evaluate an expression then bind it's value to the symbol in question:
syntax: (define {variable} {expression})
| Expression | Value |
| (define x 5) | implementation dependent |
| x | 5 |
| (define y x) | implementation dependent |
| y | 5 |
| (define x 10) | implementation dependent |
| y | 5 |
A misconception might have been that "since I bound x to y and rebound 10 to x then y should also be 10". This of course is incorrect since scheme binds the 'value' of x to y and not x itself.
The heart of scheme is the ability to create functions.
syntax: (lambda {formals} {body})
| Expression | Action | Value |
| (lambda () 1) | Create a function that takes no parameters and returns the value of the evaluation of '1' | function |
| (lambda (x y z) y) | Create a function that takes three parameters and returns the value of the 2nd parameter | function |
| (lambda five five) | Create a function that takes any number of arguments, places them in a new list, then returns that list | function |
Note the side affect of functions that take n arguments: a new list of those arguments are created.