~<#62546#>Natural numbers and recursion/looping over natural numbers play a very limited role in practical programming once we understand how to function with data structures directly rather than as array encodings. It therefore doesn't make much sense to spend a lot of time on natural numbers. <#12240#>Recommendation<#12240#>: Cover the first two sections to illustrate an unusual example of a recursive data definition. Suggest to your students to do the extended exercise on color grids on their own, because it helps them with standardized math tests.<#62546#>
The only self-referential data definitions we have seen thus far involved
<#62547#><#12241#>cons<#12241#><#62547#> and lists of arbitrary length. We needed such data
definitions because the classes of lists that we wanted to process were of
of arbitrary size. Natural numbers are another class of data whose elements
are of arbitrary size; after all, there is no limit on how large a natural
number can be and, at least in principle, a function should be able to
process them all.
In this section, we study how to describe natural numbers with
self-referential data definitions and how to develop functions that process
natural numbers in a systematic fashion. Since such functions come in many
different flavors, we study several different flavors definitions.