Search⌘ K

Lists

Explore the concept of lists in ReasonML as immutable, polymorphic variant types. Understand the list structure including head and tail, how to create lists, and calculate their length using built-in functions. This lesson helps you grasp lists as recursive data structures and prepares you for more operations in ReasonML.

The Definition

A list is an immutable data structure which stores homogenous elements (elements of the same type) in sequential form.

The reason it differs from other structures like tuples or arrays is that a list is a polymorphic variant type.

To understand why a list is a variant, we need to look at its structure.

The Structure

As a general convention in Reason, the start of a list is called the head ...