Definition. Recursive Type

[comp1110-7F]

A recursive type is a type whose instances may "contain" other ("smaller") instances of the same type. It is typically described in terms of:

  • At least one base case
  • At least one recursive case (also called "inductive case")

Base cases describe those instances that do not contain further instances of the same type.

Recursive cases describe those instances that do contain further instances of the same type.

With this, we can build very large and potentially complex data structures.

bars magnifying-glass caret-down plus minus arrow-right xmark