Simply Scheme: Introducing Computer Science, Part 1: Introduction: Functions Simply Scheme: Introducing Computer Science 2/e Copyright (C) 1999 MIT

Part I

Introduction: Functions

cover photo
Brian Harvey
University of California, Berkeley
Matthew Wright
University of California, Santa Barbara

Download PDF version
Back to Table of Contents
BACK chapter thread NEXT
MIT Press web page for Simply Scheme

The purpose of these introductory pages before each part of the book is to call attention to a big idea that runs through all the work of several chapters. In the chapters themselves, the big idea may sometimes be hidden from view because of the technical details that we need to make the idea work. If you ever feel lost in the forest, you might want to refer back here.

In these first two chapters, our goal is to introduce the Scheme programming language and the idea of using functions as the building blocks of a computation.

The first chapter is a collection of short Scheme programs, presented to show off what Scheme can do. We'll try to explain enough of the mechanism so that you don't feel completely mystified, but we'll defer the details until later. Our goal is not for you to feel that you could re-create these programs, but rather that you get a sense of what kinds of programs we'll be working with.

The second chapter explores functions in some detail. Traditionally, computer programs are built out of actions: First do this, then do that, and finally print the results. Each step in the program does something. Functional programming is different, in that we are less concerned with actions and more concerned with values.

For example, if you have a pocket calculator with a square root button, you could enter the number 3, push the button, and you'll see something like 1.732050808 in the display. How does the calculator know? There are several possible processes that the calculator could carry out. One process, for example, is to make a guess, square it, see if the result is too big or too small, and use that information to make a closer guess. That's a sequence of actions. But ordinarily you don't care what actions the calculator takes; what interests you is that you want to apply the square root function to the argument 3, and get back a value. We're going to focus on this business of functions, arguments, and result values.

Don't think that functions have to involve numbers. We'll be working with functions like "first name," "plural," and "acronym." These functions have words and sentences as their arguments and values.

(back to Table of Contents)

BACK chapter thread NEXT

Brian Harvey,