about summary refs log tree commit diff stats
path: root/js/games/nluqo.github.io/~bh/ssch1/part1.html
blob: 6b8028327370a4cafb2737f9f900ffa11c811a86 (plain) (blame)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<P>

<P>
<HTML>
<HEAD>
<TITLE>Simply Scheme: Introducing Computer Science, Part 1: Introduction: Functions</TITLE>
</HEAD>
<BODY>
<CITE>Simply Scheme:</CITE>
<CITE>Introducing Computer Science</CITE> 2/e Copyright (C) 1999 MIT
<H2>Part I</H2>
<H1>Introduction: Functions</H1>

<TABLE width="100%"><TR><TD>
<IMG SRC="../simply.jpg" ALT="cover photo">
<TD><TABLE>
<TR><TD align="right"><CITE><A HREF="http://www.cs.berkeley.edu/~bh/">Brian
Harvey</A><BR>University of California, Berkeley</CITE>
<TR><TD align="right"><CITE><A HREF="http://ccrma.stanford.edu/~matt">Matthew
Wright</A><BR>University of California, Santa Barbara</CITE>
<TR><TD align="right"><BR>
<TR><TD align="right"><A HREF="../pdf/ssch01.pdf">Download PDF version</A>
<TR><TD align="right"><A HREF="../ss-toc2.html">Back to Table of Contents</A>
<TR><TD align="right"><A HREF="../ssch0/ack.html"><STRONG>BACK</STRONG></A>
chapter thread <A HREF="showing.html"><STRONG>NEXT</STRONG></A>
<TR><TD align="right"><A HREF="http://mitpress.mit.edu/0262082810">MIT
Press web page for <CITE>Simply Scheme</CITE></A>
</TABLE></TABLE>

<HR><BIG>

<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 &quot;first name,&quot; &quot;plural,&quot; and &quot;acronym.&quot; These functions
have words and sentences as their arguments and values.

<P>
</BIG>
<HR>
<P><A HREF="../ss-toc2.html">(back to Table of Contents)</A><P>
<A HREF="../ssch0/ack.html"><STRONG>BACK</STRONG></A>
chapter thread <A HREF="showing.html"><STRONG>NEXT</STRONG></A>

<P>
<ADDRESS>
<A HREF="../index.html">Brian Harvey</A>, 
<CODE>bh@cs.berkeley.edu</CODE>
</ADDRESS>
</BODY>
</HTML>