Within a function, the arguments in the define statement are scoped as local variables, whose values are determined by the actual arguments in the call to that function. In addition, we may use define to declare global variables, and we may also use a construct called let to declare local variables in addition to those given as arguments.
Global variables may be defined as follows:
(define name value)This assigns value to a the variable name. In actuality, this operation defines a function called name, of arity 0, that always returns value. It should be noted that, as in imperative programming, global variables should be avoided except in the role of constants. That is, it is acceptable to define global variables within a Scheme program, but it is never acceptable to redefine them.
Local variables may be declared using the let construct. The syntax of let is as follows:
(let ((var1 init1) (var2 init2) ... (varN initN)) body)Within body, var1 is assigned value init1, var2 is assigned init2, and so on. Body is evaluated within the scope of these variables, and its value is returned as the value of the let.