recitation 1: scheme expressions

----------------------------------------------------------------

lectures, recitations, tutorials, textbook
problem sets, projects, collaboration, grades

edwin: 
  * to "run" scheme is to evaluate an expression/expressions
  * how to evaluate an expression [control-x control-e]
  * what to do when you have an error
  * read/eval/print loop
 
----------------------------------------------------------------

primitive expressions

    self-evaluating expressions (constants)
      boolean:  #t, #f
      numbers:  0, 1, -5, 6.001, 76120398235983942, ....
      strings: "hello", "world", "6.001", ...

    built-in procedures: +, *, sqrt, odd?, zero?, ..

    variables (check lookup table)
      - initial: defines built-in procedures
      - add to lookup table with define
      - means of abstraction

compound expressions (things in parens)

    combinations
       - prefix notation (vs. postfix or infix)
       - variable number of arguments
       - expressions as trees

    special forms
       define -global definitions
       and
       or
       if
       lambda

----------------------------------------------------------------

identifiers 
    - can't start with a number 
    - can't have white-space
    - can be upper/lower case

reserved keywords 
    =>, and, begin, case, cond, define, delay, else, 
    if, lambda, let, let*, letrec, quasiquote, quote, 
    set! unquote, unquote-splicing

variables
    - In Scheme we don't have to declare the type 
      (e.g. int, boolean, floating point, ...)

use ";"  for comments

----------------------------------------------------------------

Rules for evaluation 
1. If self-evaluating, return value. 
2. If a name, return value associated with name in environment. 
3. If a special form, do something special. 
4. If a combination, then 
   a. Evaluate all of the subexpressions of 
      combination (in any order) 
   b. Apply the operator to the values of the 
      operands (arguments) and return result

----------------------------------------------------------------

(* 2 3) =>

(*2 3) =>

((*2 3)) =>

(define a 5) =>

a =>

b =>

(define b (+ a 2)) =>

a =>

b =>

(define a 3) =>

a =>

b =>

(a) =>

(define define 4) =>

(and #t) =>

(and #t #f) =>

(and #t #f (4)) =>

(define and 5) =>