1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<HTML>
<HEAD>
<TITLE>Simply Scheme part I introduction</TITLE>
</HEAD>
<BODY>
<CITE>Simply Scheme</CITE> 2/e Copyright (C) 1999 MIT
<H1>Introduction: Functions</H1>
<TABLE><TR><TD>
<P><IMG SRC="simply.jpg" ALT="cover photo">
<TD valign="center">
<CITE><A HREF="http://www.cs.berkeley.edu/~bh/">Brian
Harvey</A><BR><A HREF="http://www.cnmat.berkeley.edu/~matt">Matthew
Wright</A><BR>University of California, Berkeley</CITE>
<BR><BR><A HREF="http://www-mitpress.mit.edu/book-home.tcl?isbn=0262082810">MIT
Press web page for Simply Scheme</A>
</TABLE>
<P><A HREF="simply-toc.html">(back to Table of Contents)</A>
<HR>
<P>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.
<P>In these first two chapters, our goal is to introduce the Scheme programming
language and the idea of using <EM>functions</EM> as the building blocks of a
computation.
<P>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
<EM>kinds</EM> of programs we'll be working with.
<P>The second chapter explores functions in some detail. Traditionally,
computer programs are built out of <EM>actions:</EM> First do this, then do
that, and finally print the results. Each step in the program <EM>does</EM>
something. Functional programming is different, in that we are less
concerned with actions and more concerned with values.
<P>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 <EM>function</EM> to the <EM>argument</EM> 3, and get back a
<EM>value.</EM> We're going to focus on this business of functions, arguments,
and result values.
<P>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.
<P><A HREF="simply-toc.html">(back to Table of Contents)</A>
</BODY>
</HTML>
|