Reading 11: Recursive Data Types
In this reading we’ll look at recursively-defined types, how to specify operations on such types, and how to implement them. Our main example will be immutable lists. Before we introduce recursive data types — which have a recursive structure of both data and computation — take a minute to review what you know about recursive functions. You should have already practiced this heavily in 6.101 (formerly called 6.009). Here are some 6.101 readings to review: If you are at all uncertain about what these terms mean and how to use them, take some time to review this 6.101 material before going on. Just as a recursive function is defined in terms of itself, a recursive data type is defined in terms of itself. We’ll see the same need for base and recursive cases, which will now appear as different variants of the abstract type. Some of our recursive types will be list-like and some will be tree-like. Consider this recursive implementation of the factorial function. For factorial(3), how many t
Reading 11: Recursive Data Types Reading 11: Recursive Data Types 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 Understand recursive data types Read and write data type definitions Understand and implement functions over recursive data types Understand immutable lists and know the standard operations on immutable lists Know and follow a recipe for writing programs with ADTs Introduction In this
Explore this link on the map →saved by
related reading
- Reading 17: Recursive Data Typesweb.mit.edu
- Reading 17: Recursive Data Typesweb.mit.edu
- Reading 19: Little Languagesweb.mit.edu
- Problem Set 3: Memelyweb.mit.edu
- Reading 13: Map, Filter, Reduceweb.mit.edu
- CSC 151 - Recursion over Numberseikmeier.sites.grinnell.edu
- CSC 151 - Recursion Over Listseikmeier.sites.grinnell.edu
- adventures in uncertainty: An Introduction to Recursion Schemesblog.sumtypeofway.com
- CSC 151 - Tail Recursioneikmeier.sites.grinnell.edu
- Reading 10: Abstract Data Typesweb.mit.edu
- CSC 151 - Higher-order design, recursive and othereikmeier.sites.grinnell.edu
- CSC 151 - Pattern matchingeikmeier.sites.grinnell.edu