Notes on the History of Scheme: LISP was invented in the late 1950's and early 1960's at M.I.T. by John McCarthy. LISP is based in part on the Lambda Calculus, a mathematical formalism developed by Alonzo Church (1903-1995).
LISP is the second-oldest language still in widespread use (the oldest is FORTRAN). Two dialects of LISP are widely used today: Scheme and Common LISP. Scheme is a small, uniform dialect that is good for teaching because of its simplicity. Common LISP is a large, ``industrial-strength'' dialect that is standardized and is available in several commercial versions. In this course, we will use one of two implementations of Scheme, called Chez Scheme and DrScheme.
Most programming languages require learning the syntax of many different kinds of statements. In contrast, Scheme (and LISP) syntax is simple and uniform. Much of the work in learning Scheme is learning the names and effects of the system functions that form the core of the language. This course presents the system functions and covers other functions that are present in Scheme.
LISP is especially used for work in Artificial Intelligence.
Steps for this Lab:
scheme in the terminal
window.
Numbers are expressions, whose value or meaning is the number
itself.
Type several numbers into Chez Scheme, typing one number at a
time. For example, at the Scheme prompt, type
7
-10
3.1415926535
In each case, note how Chez Scheme responds.
3/5
-18/19
10/34
How many digits are printed in the answer for rational numbers?
| hi | TwoBeOrNot2Be | This-is-a-symbol. |
(define pi 3.141592)
Now enter pi into Scheme and determine what happens.
Check if work with symbols within Chez Scheme is case sensitive. What happens if you type Pi or PI.
Check whether Scheme allows you to redefine the value of a symbol. For example, following the 1897 Indiana House, try to declare that the value of pi is three:
(define pi 3)
Now what happens if you type the symbol pi?Determine what happens if you make a typographical error. For example, try misspelling define or leaving out a left or right parentheses. In each case, make a note describing what happens.
(- 27 3)
(/ 17 2)
(/ 17 -2)
(/ 17 2.0)
(truncate (/ 17 4))
(modulo 17 3)
(sqrt 4)
(sin 0.5)
(sqrt -2)
(+ (* 3 2) (/ 8 4))
(modulo (truncate 12345.6789) 10)
(modulo (truncate (/ 12345.6789 10)) 10)
Explain why each of these results was obtained. Then, write an expression
using modulo, truncate, and/or / to extract the
thousands digit 2 from the number 12345.6789.
(quote pi)
(quote pi) may be abbreviated 'pi . Try typing this at
the keyboard as well.
(+ (* 2 2) 3)
(quote (+ (* 2 2) 3))
'(+ (* 2 2) 3)
('+ (* 2 2) 3)
(+ '(* 2 2) 3)
In each case, explain the result.
(define x 2)
(define y 3)
(+ x y)
(+ 'x 'y)
('+ x y)
'(+ x y)
Then try entering these lines into Scheme, and observe the results.
Be sure you can explain what happens.This document is available on the World Wide Web as
http://www.math.grin.edu/~walker/courses/151.sp00/lab-symbols.html