Heads and Tails

Learn about head, tail, and how to process lists with their help.

When we program with lists in conventional languages, we treat them as things to be iterated, meaning that it seems natural to loop over them. So, why do we have a chapter on lists and recursion? Because if we look at the problem in the right way, recursion is a perfect tool for processing lists.

Heads and tails

Earlier, we said a list may either be empty or consist of a head and a tail. The head contains a ...