Variables


Purpose

Variables have a name and store a value. This value can be a number, symbol, or list.

Usage

When a variable is evaluated, it returns its value.

Variables are usually created using the "define" function. Define requires two arguments: the name of the variable, and the value of the variable. The value argument is evaluated before it is assigned to the name.

Examples

Creating variables:
  ox --> (define name 'Matt)
  Matt
  ox --> (define frameNumber 100)
  100
Two variables, "name" and "frameNumber" have been created. They both have been assigned values:
  ox --> name
  Matt
  ox --> frameNumber
  100
Once defined, variables can be used in expressions:
  ox --> (define a 1)
  1
  ox --> (define b 2)
  2
  ox --> (+ a b) 
  3

Return to Scheme Introduction


mrl