All lessons

Stacks

7 min · OCaml examples

Last-in-first-out structure for matching brackets, undo logic, and monotonic scans.

OCaml · Stacks0/5 cleared

Enemy 1 of 5

A stack is like a pile of plates: you push on top and pop from the top. OCaml's Stack module works great — Stack.push to push, Stack.pop to pop.

Classic use: walk a string of brackets and push opens; on a close, pop and check they match.

You
Syntax Skeleton
Loading editor…
Sign up to fightThis one runs on our servers, so it needs a free account.

Stuck? Ask Rena

Your AI tutor that gives assistance.

Asking Rena in lessons is on Ultimate.