15-150: Principles of Functional Programming

In this lecture, we discussed sequences, a type of immutable data structure with constant-time access to any index of element. Importantly, their implementation is left abstract in a way such that we are only allowed to program against the API of the library, with no knowledge of its actual definition.

To explain the costs of various sequence operations, we went over a conceptual framework known as cost graphs, which let us speak of the parallel and sequential costs of various operations by graphs which represent the parallelizable and non-parallelizable work. In particular, we found that sequences are bulk data structures, and admit a very good (generally fully parallelizable) cost.

We walked through several of the operations in the SEQUENCE signature, as well as how we might implement several of them in terms of some of the other more primitive operations in the signature. We looked at one called reduce which is essentially a fold with an interesting span bound, due to admitting a "divide and conquer" implementation when invoked with an associative reducing function.

Slides