\input bkmacs \part{Composition of Functions} \justidx{composition of functions} \justidx{function composition} 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 {\tt s} to the end of a word: \smallskip \centerline{{\it add-s\/}(``{\tt run}'') = ``{\tt runs}''} \smallskip \noindent and another function that puts two words together into a sentence: \smallskip \centerline{{\it sentence\/}(``{\tt day}'', ``{\tt tripper}'') = ``{\tt day tripper}''} \smallskip \noindent We can combine these to create a new function that represents the third person singular form of a verb: \smallskip \centerline{{\it third-person\/}(verb) = {\it sentence\/}(``{\tt she}'', {\it add-s\/}(verb))} \smallskip \noindent That general formula looks like this when applied to a particular verb: \smallskip \centerline{{\it third-person\/}(``{\tt sing}'') = ``{\tt she sings}''} \smallskip \noindent The way we say it in Scheme is {\prgex% (define (third-person verb) (sentence 'she (add-s verb))) } \noindent (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.) \vfill\eject 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 ``\bkidx{functional}{programming}.'' \bye