3FUNCTION FUNDAMENTALS

Image

In the last chapter, we introduced you to Racket’s basic numerical operations. In this chapter, we’ll explore the core ideas that form the subject of functional programming.

What Is a Function?

A function can be thought of as a box with the following characteristics: if you push an object in one side, an object (possibly the same, or not) comes out the other side; and for any given input item, the same output item comes out. This last characteristic means that if you put a triangle in one side and a star comes out the other, the next time you put a triangle in, you will also get a star out (see Figure 3-1). Unfortunately, ...

Get Racket Programming the Fun Way now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.