From 562a9a52d599d9a05f871404050968a5fd282640 Mon Sep 17 00:00:00 2001 From: elioat Date: Wed, 23 Aug 2023 07:52:19 -0400 Subject: * --- js/games/nluqo.github.io/~bh/ssch3/part2.html | 85 +++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 js/games/nluqo.github.io/~bh/ssch3/part2.html (limited to 'js/games/nluqo.github.io/~bh/ssch3/part2.html') diff --git a/js/games/nluqo.github.io/~bh/ssch3/part2.html b/js/games/nluqo.github.io/~bh/ssch3/part2.html new file mode 100644 index 0000000..519a345 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/ssch3/part2.html @@ -0,0 +1,85 @@ +

+ +

+ + +Simply Scheme: Introducing Computer Science, Part 3: Composition of Functions + + +Simply Scheme: +Introducing Computer Science 2/e Copyright (C) 1999 MIT +

Part II

+

Composition of 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 big idea in this part of the book is deceptively simple. It's that we +can take the value returned by one function and use it as an argument to +another function. By “hooking up” two functions in this way, we invent a +new, third function. For example, let's say we have a function that adds +the letter s to the end of a word: + +

add-s(“run”) = “runs
+

+and another function that puts two words together into a sentence: + +

sentence(“day”, “tripper”) = “day tripper
+

+We can combine these to create a new function that represents the +third person singular form of a verb: + +

third-person(verb) = sentence(“she”, add-s(verb))
+

+That general formula looks like this when applied to a particular +verb: + +

third-person(“sing”) = “she sings
+

+The way we say it in Scheme is + +

(define (third-person verb)
+  (sentence 'she (add-s verb)))
+
+ +

(When we give an example like this at the beginning of a part, +don't worry about the fact that you don't recognize the notation. The +example is meant as a preview of what you'll learn in the coming chapters.) + +We know that this idea probably doesn't look like much of a big deal to +you. It seems obvious. Nevertheless, it will turn out that we can express +a wide variety of computational algorithms by linking functions together in +this way. This linking is what we mean by +“functional programming.” + +

+ +


+

(back to Table of Contents)

+BACK +chapter thread NEXT + +

+

+Brian Harvey, +bh@cs.berkeley.edu +
+ + -- cgit 1.4.1-2-gfad0 1 32 33 34 35 36 37 38 39 40