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.

- Little Schemer, Chapter 2
- Little Schemer, Chapter 3
- Little Schemer, Chapter 4
- Scheme Background
- EOPL 2e Chapter 1
- EOPL 2e Chapter 2
- EOPL 2e Chapter 3
- EOPL 2e Chapter 4
- EOPL 2e Chapter 5
- EOPL 2e Chapter 6

- Recursion over flat lists, without conditionals

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)

- Recursion over flat lists, with conditionals

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

- Recursion over the natural numbers

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

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

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

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

Write Scheme code to:

- Construct and lists and improper lists
- Use of quote, cons, and list primitives (and when to use each)
- Extract parts of lists and improper lists

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

Understand:

- Dot notation

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

- How to read and write our type notation (../typedscm/typedscm/typedscm.html)

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

Write Scheme code using expressions, statements, and definitions.

- Make decisions using if expressions
- Make declarations using define

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

Understand:

- Differences between expressions, statements, and declarations.

- Use of map

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

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

- Uses of curried procedures

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)

- Write variable arity procedures

sum-mod.scm (sum)

product-mod.scm (product)

atomic-tree.scm (tree)

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

- How to desugar expressions in Scheme (let, and, or, cond, case)

- Be able to use let, letrec, and, or, cond, case in Scheme programs. There are lots of examples of this. You can grep for the appropriate keyword to find examples in the library files. The following are some simple examples.

- examples of "and" and "or"

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)

- examples of "let", "let*", "letrec", and "cond", e.g.,

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

- BNF notation

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

The document defining our type notation, which uses BNF.

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

- How a grammar relates to the outline of a recursive procedure (1.2.1)

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

- Write recursive programs over flat lists (1.2.2)

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)

- Write recursive programs over other grammars (1.2.2)

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-quote-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)

- Write recursive programs over symbol-expression and lists of symbol-expressions (s-lists, pp. 19-22)

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

- Understand the difference between full recursion and tail recursion.

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.

- Write tail-recursive procedures:

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

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

- Using letrec

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

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

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

- free and bound names and variable references in an expression

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

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

- combinators

see also combinator-tools.scm

- Use of define-datatype to declare variant record types

- Abstract syntax that corresponds to a concrete syntax.

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

- Use of cases in recursive programming, especially over some abstract syntax.

../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?)

- Representation types and defrep

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.

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