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

CSC 151 - Recursion over Numbers

eikmeier.sites.grinnell.edu · 1,588 words · saved by 1 readers

Our recursive functions mirror this recursive definition. So it stands to reason that if we are able to give a recursive definition for any type, then we can perform recursion over that type similarly! Many kinds of data admit recursive definitions, and you will encounter many of them throughout your computer science journey. However, there is one datatype that trumps them all—perhaps even more so than a list! It is the natural number. Recall that the natural numbers are the non-negative integers. This includes the numbers 0 0 , 1 1 , 2 2 , 3 3 , …, etc. Our definition of a list was recursive because at least one of the cases included a smaller list inside itself. We can see via the picture where the smaller list is located: it’s the tail of the list! However, now let’s consider a natural number, say 5 5 : Ugh. Unlike lists, it is not immediately obvious what the “smaller” natural number is in this situation. Where is it hiding? One way to discover where the smaller natural number

CSC 151 - Recursion over Numbers Recursion over Numbers Due Friday, 17 October 2025 --> The heart of our recursive functions so far is our recursive definition of lists: A list is either: Empty ( null ) or Non-empty ( ( cons head tail ) ) with a head element and a sub-list, its tail . Our recursive functions mirror this recursive definition. So it stands to reason that if we are able to give a recursive definition for any type, then we can perform recursion over that type similarly! Many kinds of data admit recursive definitions, and you will encounter many of them throughout your computer sci

Explore this link on the map →

saved by

related reading