- Scheme expressions, or commands, always go within a pair of parenthesis. For example:
(define x 100)
This expression defines a new variable named "x" and gives it the value "10." - After a variable is defined, it can be reset using the "set!" command, like so:
(set! x 50) - It is possible in Scheme to define procedures and so short sub programs, using the keyword "lambda:"
(define square (lambda (x) (* x x)))
Notice how the parenthesis match up. This defines a procedure named "square" that takes one argument "x" and multiplies it against itself (* x x). Notice, Scheme arithmetic operations take the operator first, then the numbers on which to perform the problem. - You can use your newly defined procedure with the following command:
(define xSquared (square 10))
This will store the value "100" in the variable named "xSquared."
previous post