Scheme Programming Help

Scheme is a programming language developed at MIT in 1975. It is sometimes used as an introductory programming language due to its relatively simple syntax and ability to function within multiple programming paradigms, including functional, imperative and object-oriented design.

  1. Parenthesis

    • 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."

    Assignments

    • After a variable is defined, it can be reset using the "set!" command, like so:

      (set! x 50)

    Procedures

    • 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.

    Usage

    • 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."

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured