Programming Languages (CSC-302 99S)

Class 06: Laboratory Session: Scheme

Back to Untyped Functional Programming in Scheme. On to Continuations.

Held Friday, February 5




Higher-order functions

Anonymous functions


You are not required to turn in anything for the lab. However, you are expected to consider as many of these questions as you can. You are encouraged to work with other students. Those who survived the Scheme-based introduction are encouraged to act as TAs.

Use map to square all the elements of some sequence.

Use map to increment all the elements of some sequence.

Write a function, makepairs that, given two lists, makes the list of pairs of elements from those two lists. For example (makepairs '(1 2 3) '(a b c)) should create the list ((1 a) (2 b) (3 c)). You should write makepairs recursive. Do not use map to write this function.

Rewrite makepairs without recursive calls, using map.

Write a function, mappairs, that applies a binary function to each pair in a list of pairs, creating a list of results. jor example, (mappairs * '((1 2) (2 3) (3 4))) should give (2 6 12).

Write a function, sum, that sums the elements in a list. For example, (sum '(1 2 3)) should give 6.

Using all of these functions, write innerProduct that computes the inner product of two vectors.

If you still have time, start work on assignment two.


Back to Untyped Functional Programming in Scheme. On to Continuations.

Disclaimer Often, these pages were created ``on the fly'' with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.

This page may be found at

Source text last modified Fri Feb 5 13:03:36 1999.

This page generated on Fri Feb 5 13:05:35 1999 by SiteWeaver. Validate this page.

Contact our webmaster at