summary refs log tree commit diff stats
path: root/doc/apis.txt
blob: 277c1925b9f6474753e834ae14920b5a00cddaa6 (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
=================
API naming design
=================

The API is designed to be **easy to use** and consistent. Ease of use is
measured by the number of calls to achieve a concrete high level action.


Naming scheme
=============

The library uses a simple naming scheme that makes use of common abbreviations
to keep the names short but meaningful. Since version 0.8.2 many symbols have
been renamed to fit this scheme. The ultimate goal is that the programmer can
*guess* a name.


-------------------     ------------   --------------------------------------
English word            To use         Notes
-------------------     ------------   --------------------------------------
initialize              initT          ``init`` is used to create a
                                       value type ``T``
new                     newP           ``new`` is used to create a
                                       reference type ``P``
find                    find           should return the position where
                                       something was found; for a bool result
                                       use ``contains``
contains                contains       often short for ``find() >= 0``
append                  add            use ``add`` instead of ``append``
compare                 cmp            should return an int with the
                                       ``< 0`` ``== 0`` or ``> 0`` semantics;
                                       for a bool result use ``sameXYZ``
put                     put, ``[]=``   consider overloading ``[]=`` for put
get                     get, ``[]``    consider overloading ``[]`` for get;
                                       consider to not use ``get`` as a
                                       prefix: ``len`` instead of ``getLen``
length                  len            also used for *number of elements*
size                    size, len      size should refer to a byte size
capacity                cap
memory                  mem            implies a low-level operation
items                   items          default iterator over a collection
pairs                   pairs          iterator over (key, value) pairs
delete                  delete, del    del is supposed to be faster than
                                       delete, because it does not keep
                                       the order; delete keeps the order
remove                  delete, del    inconsistent right now
include                 incl
exclude                 excl
command                 cmd
execute                 exec
environment             env
variable                var
value                   value, val     val is preferred, inconsistent right
                                       now
executable              exe
directory               dir
path                    path           path is the string "/usr/bin" (for
                                       example), dir is the content of
                                       "/usr/bin"; inconsistent right now
extension               ext
separator               sep
column                  col, column    col is preferred, inconsistent right
                                       now
application             app
configuration           cfg
message                 msg
argument                arg
object                  obj
parameter               param
operator                opr
procedure               proc
function                func
coordinate              coord
rectangle               rect
point                   point
symbol                  sym
literal                 lit
string                  str
identifier              ident
indentation             indent
-------------------     ------------   --------------------------------------
ref='#n350'>350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
<HTML>
<HEAD>
<TITLE>Simply Scheme contents</TITLE>
<link rel="shortcut icon" href="http://www.cs.berkeley.edu/~bh/simply.png" type="image/png">
</HEAD>
<BODY>
<H1><CITE>Simply Scheme:<BR>Introducing Computer Science</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 <CITE>Simply Scheme</CITE></A>
</TABLE>

<P><TABLE><TR><TD><A HREF="ss/foreword.html"><H3>Foreword</H3></A>
<TD>by Hal Abelson</TABLE>

<H3><A HREF="https://people.eecs.berkeley.edu/~bh/ss/preface">Preface</A></H3>
<UL>
<LI>One Big Idea: Symbolic Programming
<LI>Lisp and Radical Computer Science
<LI>Who Should Read This Book
<LI>How to Read This Book
</UL>

<H3><A HREF="ss/instructor.html">To the Instructor</A></H3>
<UL>
<LI>Lists and Sentences
<LI>Sentences and Words
<LI>Overloading in the Text Abstraction
<LI>Higher-Order Procedures, Lambda, and Recursion
<LI>Mutators and Environments
</UL>

<H3><A HREF="ss/ack.html">Acknowledgments</A></H3>

<P><EM>(Note: The links on the Part headings below point to the
introductions to the major parts of the book, each introducing one
"big idea."  Each introduction is about a page of text.)</EM>

<A HREF="part1.html"><H2>Part I. Introduction: Functions</H2></A>

<H3>1. Showing Off Scheme</H3>
<UL>
<LI>Talking to Scheme
<LI>Recovering from Typing Errors
<LI>Exiting Scheme
<LI>More Examples
<LI>Example: Acronyms
<LI>Example: Pig Latin
<LI>Example: Ice Cream Choices
<LI>Example: Combinations from a Set
<LI>Example: Factorial
<LI>Play with the Procedures
</UL>

<H3>2. Functions</H3>
<UL>
<LI>Arithmetic
<LI>Words
<LI>Domain and Range
<LI>More Types: Sentences and Booleans
<LI>Our Favorite Type: Functions
<LI>Play with It
<LI>Thinking about What You've Done
</UL>

<A HREF="part2.html"><H2>Part II. Composition of Functions</H2></A>

<H3>3. Expressions</H3>
<UL>
<LI>Little People
<LI>Result Replacement
<LI>Plumbing Diagrams
<LI>Pitfalls
</UL>

<H3>4. Defining Your Own Procedures</H3>
<UL>
<LI>How to Define a Procedure
<LI>Special Forms
<LI>Functions and Procedures
<LI>Argument Names versus Argument Values
<LI>Procedure as Generalization
<LI>Composability
<LI>The Substitution Model
<LI>Pitfalls
</UL>

<H3>5. Words and Sentences</H3>
<UL>
<LI>Selectors
<LI>Constructors
<LI>First-Class Words and Sentences
<LI>Pitfalls
</UL>

<H3>6. True and False</H3>
<UL>
<LI>Predicates
<LI>Using Predicates
<LI><CODE>If</CODE> Is a Special Form
<LI>So Are <CODE>And</CODE> and <CODE>Or</CODE>
<LI>Everything That Isn't False Is True
<LI>Decisions, Decisions, Decisions
<LI><CODE>If</CODE> Is Composable
<LI>Pitfalls
</UL>

<H3>7. Variables</H3>
<UL>
<LI>How Little People Do Variables
<LI>Global and Local Variables
<LI>The Truth about Substitution
<LI><CODE>Let</CODE>
<LI>Pitfalls
</UL>

<A HREF="part3.html"><H2>Part III. Functions as Data</H2></A>

<H3>8. Higher-Order Functions</H3>
<UL>
<LI><CODE>Every</CODE>
<LI>A Pause for Reflection
<LI><CODE>Keep</CODE>
<LI><CODE>Accumulate</CODE>
<LI>Combining Higher-Order Functions
<LI>Choosing the Right Tool
<LI>First-Class Functions and First-Class Sentences
<LI><CODE>Repeated</CODE>
<LI>Pitfalls
</UL>

<H3>9. Lambda</H3>
<UL>
<LI>Procedures That Return Procedures
<LI>The Truth about <CODE>Define</CODE>
<LI>The Truth about <CODE>Let</CODE>
<LI>Name Conflicts
<LI>Named and Unnamed Functions
<LI>Pitfalls
</UL>

<H3>Project: Scoring Bridge Hands</H3>

<H3>10. Example: Tic-Tac-Toe</H3>
<UL>
<LI>A Warning
<LI>Technical Terms in Tic-Tac-Toe
<LI>Thinking about the Program Structure
<LI>The First Step: Triples
<LI>Finding the Triples
<LI>Using <CODE>Every</CODE> with Two-Argument Procedures
<LI>Can the Computer Win on This Move?
<LI>If So, in Which Square?
<LI>Second Verse, Same as the First
<LI>Now the Strategy Gets Complicated
<LI>Finding the Pivots
<LI>Taking the Offensive
<LI>Leftovers
<LI>Complete Program Listing
</UL>

<A HREF="https://people.eecs.berkeley.edu/~bh/part4.html"><H2>Part IV. Recursion</H2></A>

<H3>11. Introduction to Recursion</H3>
<UL>
<LI>A Separate Procedure for Each Length
<LI>Use What You Have to Get What You Need
<LI>Notice That They're All the Same
<LI>Notice That They're Almost All the Same
<LI>Base Cases and Recursive Calls
<LI>Pig Latin
<LI>Problems for You to Try
<LI>Our Solutions
<LI>Pitfalls
</UL>

<H3>12. The Leap of Faith</H3>
<UL>
<LI>From the Combining Method to the Leap of Faith
<LI>Example: <CODE>Reverse</CODE>
<LI>The Leap of Faith
<LI>The Base Case
<LI>Example: <CODE>Factorial</CODE>
<LI>Likely Guesses for Smaller Subproblems
<LI>Example: <CODE>Downup</CODE>
<LI>Example: <CODE>Evens</CODE>
<LI>Simplifying Base Cases
<LI>Pitfalls
</UL>

<H3>13. How Recursion Works</H3>
<UL>
<LI>Little People and Recursion
<LI>Tracing
<LI>Pitfalls
</UL>

<H3>14. Common Patterns in Recursive Procedures</H3>
<UL>
<LI>The <CODE>Every</CODE> Pattern
<LI>The <CODE>Keep</CODE> Pattern
<LI>The <CODE>Accumulate</CODE> Pattern
<LI>Combining Patterns
<LI>Helper Procedures
<LI>How to Use Recursive Patterns
<LI>Problems That Don't Follow Patterns
<LI>Pitfalls
</UL>

<H3>Project: Spelling Names of Huge Numbers</H3>

<H3>15. Advanced Recursion</H3>
<UL>
<LI>Example: <CODE>Sort</CODE>
<LI>Example: <CODE>From-Binary</CODE>
<LI>Example: <CODE>Mergesort</CODE>
<LI>Example: <CODE>Subsets</CODE>
<LI>Pitfalls
</UL>

<H3>Project: Scoring Poker Hands</H3>
<UL>
<LI>Extra Work for Hotshots
</UL>

<H3>16. Example: Pattern Matcher</H3>
<UL>
<LI>Problem Description
<LI>Implementation: When Are Two Sentences Equal?
<LI>When Are Two Sentences Nearly Equal?
<LI>Matching with Alternatives
<LI>Backtracking
<LI>Matching Several Words
<LI>Combining the Placeholders
<LI>Naming the Matched Text
<LI>The Final Version
<LI>Abstract Data Types
<LI>Backtracking and <CODE>Known-Values</CODE>
<LI>How We Wrote It
<LI>Complete Program Listing
</UL>

<A HREF="part5.html"><H2>Part V. Abstraction</H2></A>

<H3>17. Lists</H3>
<UL>
<LI>Selectors and Constructors
<LI>Programming with Lists
<LI>The Truth about Sentences
<LI>Higher-Order Functions
<LI>Other Primitives for Lists
<LI>Association Lists
<LI>Functions That Take Variable Numbers of Arguments
<LI>Recursion on Arbitrary Structured Lists
<LI>Pitfalls
</UL>

<H3>18. Trees</H3>
<UL>
<LI>Example: The World
<LI>How Big Is My Tree?
<LI>Mutual Recursion
<LI>Searching for a Datum in the Tree
<LI>Locating a Datum in the Tree
<LI>Representing Trees as Lists
<LI>Abstract Data Types
<LI>An Advanced Example: Parsing Arithmetic Expressions
<LI>Pitfalls
</UL>

<H3>19. Implementing Higher-Order Functions</H3>
<UL>
<LI>Generalizing Patterns
<LI>The <CODE>Every</CODE> Pattern Revisited
<LI>The Difference between <CODE>Map</CODE> and <CODE>Every</CODE>
<LI><CODE>Filter</CODE>
<LI><CODE>Accumulate</CODE> and <CODE>Reduce</CODE>
<LI>Robustness
<LI>Higher-Order Functions for Structured Lists
<LI>The Zero-Trip Do Loop
<LI>Pitfalls
</UL>

<A HREF="part6.html"><H2>Part VI. Sequential Programming</H2></A>

<H3>20. Input and Output</H3>
<UL>
<LI>Printing
<LI>Side Effects and Sequencing
<LI>The <CODE>Begin</CODE> Special Form
<LI>This Isn't Functional Programming
<LI>Not Moving to the Next Line
<LI>Strings
<LI>A Higher-Order Procedure for Sequencing
<LI>Tic-Tac-Toe Revisited
<LI>Accepting User Input
<LI>Aesthetic Board Display
<LI>Reading and Writing Normal Text
<LI>Formatted Text
<LI>Sequential Programming and Order of Evaluation
<LI>Pitfalls
</UL>

<H3>21. Example: The <CODE>Functions</CODE> Program</H3>
<UL>
<LI>The Main Loop
<LI>The Difference between a Procedure and Its Name
<LI>The Association List of Functions
<LI>Domain Checking
<LI>Intentionally Confusing a Function with Its Name
<LI>More on Higher-Order Functions
<LI>More Robustness
<LI>Complete Program Listing
</UL>

<H3>22. Files</H3>
<UL>
<LI>Ports
<LI>Writing Files for People to Read
<LI>Using a File as a Database
<LI>Transforming the Lines of a File
<LI>Justifying Text
<LI>Preserving Spacing of Text from Files
<LI>Merging Two Files
<LI>Writing Files for Scheme to Read
<LI>Pitfalls
</UL>

<H3>23. Vectors</H3>
<UL>
<LI>The Indy 500
<LI>Vectors
<LI>Using Vectors in Programs
<LI>Non-Functional Procedures and State
<LI>Shuffling a Deck
<LI>More Vector Tools
<LI>The Vector Pattern of Recursion
<LI>Vectors versus Lists
<LI>State, Sequence, and Effects
<LI>Pitfalls
</UL>

<H3>24. Example: A Spreadsheet Program</H3>
<UL>
<LI>Limitations of Our Spreadsheet
<LI>Spreadsheet Commands
<LI>Moving the Selection
<LI>Putting Values in Cells
<LI>Formulas
<LI>Displaying Formula Values
<LI>Loading Spreadsheet Commands from a File
<LI>Application Programs and Abstraction
</UL>

<H3>25. Implementing the Spreadsheet Program</H3>
<UL>
<LI>Cells, Cell Names, and Cell IDs
<LI>The Command Processor
<LI>Cell Selection Commands
<LI>The <CODE>Load</CODE> Command
<LI>The <CODE>Put</CODE> Command
<LI>The Formula Translator
<LI>The Dependency Manager
<LI>The Expression Evaluator
<LI>The Screen Printer
<LI>The Cell Manager
<LI>Complete Program Listing
</UL>

<H3>Project: A Database Program</H3>
<UL>
<LI>A Sample Session with Our Database
<LI>How Databases Are Stored Internally
<LI>The Current Database
<LI>Implementing the Database Program Commands
<LI>Additions to the Program
<LI>Extra Work for Hotshots
</UL>

<A HREF="part7.html"><H2>Part VII. Conclusion: Computer Science</H2></A>

<H3>26. What's Next?</H3>
<UL>
<LI>The Best Computer Science Book
<LI>Beyond <CITE>SICP</CITE>
<LI>Standard Scheme
<LI>Last Words
</UL>

<H2>Appendices</H2>

<H3>A. Running Scheme</H3>
<UL>
<LI>The Program Development Cycle
<LI>Integrated Editing
<LI>Getting Our Programs
<LI>Tuning Our Programs for Your System
<LI>Loading Our Programs
<LI>Versions of Scheme
<LI>Scheme Standards
</UL>

<H3>B. Common Lisp</H3>
<UL>
<LI>Why Common Lisp Exists
<LI>Defining Procedures and Variables
<LI>The Naming Convention for Predicates
<LI>No Words or Sentences
<LI>True and False
<LI>Files
<LI>Arrays
<LI>Equivalents to Scheme Primitives
<LI>A Separate Name Space for Procedures
<LI><CODE>Lambda</CODE>
<LI>More about <CODE>Function</CODE>
<LI>Writing Higher-Order Procedures
</UL>

<H3>C. Scheme Initialization File</H3>

<H3>D. GNU General Public License</H3>
<H3>Credits</H3>
<H3>Alphabetical Table of Scheme Primitives</H3>
<H3>Glossary</H3>
<H3>Index of Defined Procedures</H3>
<H3>General Index</H3>

<P>
<A HREF="http://mitpress.mit.edu/0262082810">MIT
Press web page for <CITE>Simply Scheme</CITE></A>

<P>
<ADDRESS>
<A HREF="index.html">Brian Harvey</A>, 
<CODE>bh@cs.berkeley.edu</CODE>
</ADDRESS>
<BR>
<ADDRESS>
<A HREF="http://www.cnmat.berkeley.edu/~matt">Matthew Wright</A>,
<CODE>matt@cnmat.berkeley.edu</CODE>
</ADDRESS>
</BODY>
</HTML>