Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Paste a linked list or a tree below to visualize it. Paste more than one to draw them all.

Loading...

For a linked list, each Link is a pair of boxes containing its first (left box) and rest (right box) attributes. A slash in the rest box is an empty linked list. An item that is itself a linked list points down to a row of its own.

A tree is drawn with each label above its branches and an arrow from the label to the root of each branch.

A tree can also be written in Gleam, using the type from the Gleam chapters: Tree(1, [leaf(2), Tree(3, [leaf(4)])]), or a tree as echo prints it.

pub type Tree(a) {
  Tree(label: a, branches: List(Tree(a)))
}

pub fn leaf(label: a) -> Tree(a) {
  Tree(label, [])
}

This page doesn’t evaluate Python or Gleam code. It just visualizes linked lists and trees. Values contained within them are shown as written.