flâneur — a map of the web's best reading

Reading 13: Map, Filter, Reduce

web.mit.edu · 5,870 words · saved by 1 readers

In this reading you’ll learn a design pattern for implementing functions that operate on sequences of elements, and you’ll see how treating functions themselves as first-class values that we can pass around and manipulate in our programs is an especially powerful idea. Let’s start by reviewing an important Big Idea that you should have already encountered in 6.101 [formerly 6.009]: functions as first-class data values, meaning that they can be stored in variables, passed as arguments to functions, and created dynamically like other values. For example, Math.sqrt is a reference to an object representing the sqrt function. The type of that object is (x: number) => number. But you can also assign that function object to another variable if you like, and it still behaves like sqrt: The type that we declared on mySquareRoot is a function type expression. Note that the parameter name x is required! If you write (number) => number, it means “a function with a parameter named number of type an

Reading 13: Map, Filter, Reduce Reading 13: Map, Filter, Reduce Software in 6.102 Safe from bugs Easy to understand Ready for change Correct today and correct in the unknown future. Communicating clearly with future programmers, including future you. Designed to accommodate change without rewriting. Objectives In this reading you’ll learn a design pattern for implementing functions that operate on sequences of elements, and you’ll see how treating functions themselves as first-class values that we can pass around and manipulate in our programs is an especially powerful idea. Map/filter/reduce

Explore this link on the map →

saved by

related reading