[Index of Lectures]

[ L01 L02 L03 L04 L05 L06 L07 L08 L09 L10 L11 L12 L13 L14 L15 L16 L17 L18 L19 L20 L21 L22 L23 ]

Lecture 10—Mutual reference and mutual recursion

Before Lecture

Before lecture 10, please work through the videos in Module 6b: Mutually Recursive Data and Templating Mutual Recursion and complete the online questions for this module.

During Lecture

The starters for this lecture are:

After Lecture

Today we covered what may seem like a complex concept — Mutual Reference. When Working with types that have mutual reference we are operating on data far more complicated than a few weeks ago.

But here's where all the work you have done so far really starts to pay off. We can use our notation for types, we can form templates for those types, we understand reference, self-reference and now mutual reference, we know about positions in templates, particularly base and combination positions, we have guidelines for forming tests for functions. And we know how to trust the natural recursions!

That means that we can write each of the functions in a mutual recursion without having to think through all the calls. Which makes these functions not much harder than functions on lists from module 4.

So the one really new thing we learned in this module really was that when we design functions on mutually referential data we group the signature/purpose/examples/definitions differently. The rest was just HtDF!

We also learned the backtracking template, which gets added into our type based templates to do a backtracking search over a tree. We will see this again and again as we go forward.

To review what you learned today: