[doowop6] ~ $ mzscheme
Welcome to MzScheme v4.1.2 [3m], Copyright (c) 2004-2008 PLT Scheme Inc.
> ; comments start with a semicolon

> ;; the fundamental aggregate data structure is the list
'(1 2 3 4)
(1 2 3 4)
;;; the quote ' tells the interpreter to treat what follows
  ;; as data (i.e. list or symbol) not as an expression
> ;; nested list
'(1 2 (3 4) 5)
(1 2 (3 4) 5)

> ;; compound expressions are always of the form (...)
(+ 1 2)
3
> (* (+ 1 2) (- 2 1))
3

> ;; list manipulation
;; (car L) returns the first element of list L
(car '(1 2 3 4))
1
> ;; (cdr L) returns a list containing all but the first element of L
(cdr '(1 2 3 4))
(2 3 4)

> ;; how can we return the second element of the list L
> (car (cdr '(1 2 3 4)))
2
> (cadr '(1 2 3 4))
2


> ;; define variable
(define x 'one)
> x
one
> y
reference to undefined identifier: y
> (define y '(1 2 3 4)
> y
(1 2 3 4)

> ;; (cons x L) create a new list whose first element is x and
;;;; whose subsequent elements are the elements of L
(define y (cons x null))
> y
(one)
> x
one
> (car y)
one
> (cdr y)
()

> ;;scheme is based on lambda calculus
;;;;we can define a function using lambda
 (define f
        (lambda (x y z)
                (+ x (/ y z))))
> (f 3 20 2)
13
>