Course Library Code Examples

This page gives access to code examples in the course library.

You can use the table of contents (on the web) to jump directly to the kind of example you are looking for.

If you click on a Scheme file name and your browser tries to download a plugin (e.g., for a Lotus Screen Cam Movie), then you need to change your browser's rules for associating file suffixes with viewers. One way to do this on Windows (95/98) is to go into the Windows Explorer, and click on "View" then "Folder Options", then click on the "File Types" tab, and then enter a new file type for .scm files.


Contents

  1. Little Schemer, Chapter 2
  2. Little Schemer, Chapter 3
  3. Little Schemer, Chapter 4
  4. Scheme Background
  5. EOPL 2e Chapter 1
  6. EOPL 2e Chapter 2
  7. EOPL 2e Chapter 3
  8. EOPL 2e Chapter 4
  9. EOPL 2e Chapter 5
  10. EOPL 2e Chapter 6

The Little Schemer, Chapter 2

list-copy-mod.scm, list-copy is a prototype for these kinds of procedures, although it doesn't seem to do much.

list-length-mod.scm (list-length)

add1-to-each-mod.scm (add1-to-each)

make-all-positive-mod.scm (make-all-positive)

mapcdr-mod.scm (mapcdr)

list-map-mod.scm (list-map)

The Little Schemer, Chapter 3

delete-even-mod.scm (delete-even)

The Little Schemer, Chapter 4

nat-leq-mod.scm (nat-leq)

nth-element-mod.scm (nth-element)

unary-notation-mod.scm (unary-notation)

expt-maker-mod.scm (expt-maker)

Scheme Background

Scheme Data Types

Write Scheme code to:

yodaize-mod.scm

whos-on-first-mod.scm

lambda*.scm, for example lambda-1-exp.scm

Understand:

dot-notation-mod.scm (dot-notation)

In most files have type annotations (try the Unix command: grep deftype *.scm)

Scheme Expressions

Write Scheme code using expressions, statements, and definitions.

nth-element-mod.scm (nth-element), among many other examples in lib.

Understand:

Scheme Procedures

matrix-ops.scm

sym-exp-mod.scm (parse-s-list)

remove-sym-exp-with-map.scm (remove-s-list)

grav-force-example.scm

expt-maker-mod.scm (expt-maker)

../typedscm/testing.scm (testing:eval-print-maker, testing:regression-test-maker-maker, ...)

../typedscm/tc-type-helpers.scm (tc:axiom-helper, tc:rule-helper, etc.)

vector-generator-mod.scm (see vector-generator-mod.tst and vector-map-mod.scm for how it's used)

sum-mod.scm (sum)

product-mod.scm (product)

atomic-tree.scm (tree)

set-ops-as-vector.scm (set-of, set-union*)

Syntactic Abstraction in Scheme

nat-leq-mod.scm (nat-leq)

set-ops-as-vector.scm (set-member?, set-subset?, set-equal?)

all-mod.scm (all)

some-mod.scm (some)

../typedscm/tc-type-helpers.scm (tc:rule-or-helper, tc:sequence)

whos-on-first-mod.scm

../typedscm/tc-type-helpers.scm (tc:sequence, ...)

EOPL Chapter 1

Inductive Specifications and Grammars (1.1)

lambda*.scm, for example lambda-1-exp.scm

The document defining our type notation, which uses BNF.

../typedscm/tc-output-type-expr.scm

Deriving Recursive Programs from Grammars (1.2)

See also Gary T. Leavens, `` Following the Grammar,'' Department of Computer Science, Iowa State University, TR #05-02a, February 2005, revised January 2006.

sum-mod.scm (sum-of-list)

product-mod.scm (product-of-list)

../typedscm/tc-util.scm (tc:last-item, tc:some, tc:member?, tc:filter, tc:find-duplicates, ...)

../typedscm/chez/tc-ignore-types-at-runtime.scm (list-of)

select-outerwear-mod.scm (select-outerwear), which is an example using the temperature grammar (only alternatives, no recursion).

iseq-map-mod.scm (iseq-map), which is an example using the infinite sequence grammar (only recursion, no alternatives).

valid-number-mod.scm (valid-number), which is an example using the phone number grammar (multiple nonterminals, no recursion).

double-size-mod.scm (double-size) which is an example using the window-layout grammar.

negate-bexp-mod.scm (negate-bexp), which is an example using the boolean expression grammar.

targets-mod.scm (targets), which is an example using the statement-expression grammar.

remove-named-mod.scm (remove-named), which is an example using the SXML grammar (an abstract syntax for XML).

lambda-1-exp-examples.scm

lambda-1-quote-exp-examples.scm

lambda-if-exp-examples.scm

../typedscm/tc-output-type-expr.scm

../typedscm/tc-type-translate.scm (tc:type-vars, tc:output-type-vars, tc:nest-args, tc:type-unnest-args, tc:substq-all-output)

count-sym-exp-mod.scm

subst-mod.scm

num-of-mod.scm

remove-sym-exp-mod.scm

try these using sym-exp-cooked.scm, also instead of sym-exp-mod.scm

Tail Recursion (1.2.3)

Examples of full recursion are found in the section above on deriving recursive programs from grammars. Compare the code for the fully recursive product-mod.scm with the tail recursive code in product-tail-recursive.scm. Note the pending computations surrounding the recursive calls in the fully-recursive version.

product-tail-recursive.scm

list-index-find.scm

vector-product-mod.scm

../typedscm/tc-util.scm (tc:last-item)

vector-map-bang-mod.scm (vector-map!)

whos-on-first-mod.scm (get-context, try-strong-cues, try-weak-cues)

set-ops-as-vector.scm

../typedscm/tc-util.scm (tc:find-duplicates)

vector-generator-mod.scm

../typedscm/chez/tc-ignore-types-at-runtime.scm (vector-of)

Scope and Binding of Variables (1.3)

lambda-1-exp-examples.scm (free-vars, free?, bound-vars, bound?)

combinator-tools.scm (occurs-free-in?)

combinators.scm

combinators-fix-point.scm

see also combinator-tools.scm

EOPL Chapter 2

Specifying Data via Interfaces (2.1)

Abstraction for Inductive Data Types (2.2)

lambda-1-exp-as-ast.scm

lambda-1-quote-exp-as-ast.scm

lambda-1-exp-as-ast.scm

lambda-1-quote-exp-as-ast.scm

The abstract syntax in chapter 3 of the EOPL text is a classic example of this.

arith-expr-examples.scm

../typedscm/tc-type-translate.scm (tc:type-vars, tc:external-type-vars, tc:nest-args, tc:type-unnest-args, tc:substq-all-external)

combinator-tools.scm (toCombinators, interpret, toLambda, occurs-free-in?)

Data Abstraction (2.3)

sym-cell-mod.scm

set-ops-as-vector.scm

ratl-mod.scm

statement-expression.scm

iseq-mod.scm

seq-as-proc.scm

seq-as-ast.scm

temperature-mod.scm

window-layout-mod.scm

Transformation of Procedural to Abstract Syntax Tree Representations (2.3.2-2.3.3)

seq-as-proc.scm transformed to seq-as-ast.scm. The library also has some representation-independent tests for these that are used by seq-as-proc.tst and seq-as-ast.tst.

environment-as-proc.scm transformed to environment-as-ast.scm. See also the optimized ribcage representation in environment-as-ribcage.scm. The library also has some representation-independent tests for these that are used by environment-as-proc.tst, environment-as-ast.tst, and environment-as-ribcage.tst.

phone-book-as-proc.scm transformed to phone-book-as-ast.scm and optimized to a ribcage representation in phone-book-as-ribcage.scm The library also has some representation-independent tests for these that are used by phone-book-as-proc.tst, phone-book-as-ast.tst, and phone-book-as-ribcage.tst.

road-map-as-proc.scm transformed to road-map-as-ast.scm The library also has some representation-independent tests for these that are used by road-map-as-proc.tst and road-map-as-ast.tst.

EOPL Chapter 3

Simple Interpreter (3.1-3.2)

ch3-1.scm

ch3-1-modified-in-class.scm

Conditionals (3.3)

ch3-1-modified-in-class.scm

Local Binding (3.4)

ch3-4.scm

ch3-4-modified-in-class.scm

Procedures (3.5)

ch3-5.scm

ch3-5-modified-in-class.scm

ch3-5-reducer.scm

Recursion (3.6)

ch3-6-1.scm

ch3-6-1-modified-in-class.scm

ch3-6-2.scm

ch3-6-2-modified-in-class.scm

ch3-6-3.scm

Variable Assignment (3.7)

ch3-7.scm

ch3-7-modified-in-class.scm

ch3-9.scm

Parameter Passing Variations (3.8)

ch3-8ref.scm

ch3-8name.scm

ch3-8need.scm

Statements (3.9)

ch3-9.scm

ch3-7-modified-in-class.scm

EOPL Chapter 5

Object-Oriented Concepts (5.1-5.2)

The Language (5.3)

ch5-3.scm

Four Implementations (5.4)

ch5-4-1.scm

ch5-4-2.scm

ch5-4-3.scm

ch5-4-4.scm


Last modified $Date: 2006/04/20 02:27:50 $.