Table of ContentsThe SchemeProgramming Language Scheme philosophy Scheme C vs. Scheme expressions Prefix vs. infix Nested expressions 1 Nested expressions 2 Nested expressions 3 Nested expressions 4 Nested expressions 5 Evaluating arguments Types More types What’s in a symbol? Some “literals”evaluate to themselves Symbols evaluate byvariable lookup define special form Lists evaluate byprocedure application* Special forms List evaluation Creating symbol value Suppressing evaluation quote special form Quoting Forcing evaluation with eval The Lambda Calculus Creating procedures withthe lambda special form A moment for syntax Naming a procedure Shorthand forprocedure definition Procedures vs. variables Conditionals:if special form C vs. Scheme C vs. Scheme eq? proceduretests for identity equality Recursion Linear recursive process Lists are made of cons cells cons cells and thecons procedure List syntax shorthand Beware the arrow:Another look at lists car, cdr, and friends Nested lists Do not try this at home our-list-ref procedure our-list-ref traceLinear iterative process Contrast theinductive steps Tail-recursion our-list-ref tail recursion Re-binding is NOT assignment Iterative version offactorial Iterative factorial trace Nested procedure defines Factoring outcommon sub-expressions let special form Scope is visibility let bindings happenin parallel Bad let bindings let* special form More about conditionals:cond special form cond example Short-circuiting and, orspecial forms Boolean values & and, or Procedures are first-class values map, a higher-order function Filter procedure Typechecking predicates Procedure factories Building procedures Dr. Scheme Graphics lambdas and closures lambdas andtheir environments Free variables andLexical Scoping Dynamic Scoping Lexical vs. Dynamic Scope Lexical scopeand variable hiding When the arguments don’t fit A more direct approach:the apply procedure Procedure arity Rest arguments Controlling evaluationinside of lists quasiquote and unquote Forcing and suppressingevaluation are fundamental Comparisons eq?, eqv?, equal? More eq?, eqv?, equal? Objects/values in theScheme Heap Do not use eq? for numbers Making new lists Sharing of list structure append mustduplicate the list List surgery set-cdr! and set-car! Assignment set! procedure Other side-effects Sequencing andthe begin special form |
Author: Greg J. Badros
Email: badros@cs.washington.edu Home Page: http://www.cs.washington.edu/education/courses/341/CurrentQtr |