Parsing nested lists in BQN

01/23/2023

Three ways to parse the nested lists from Advent of Code 2022 day 13 in BQN.


Advent of Code 2022 day 13 requires you to parse nested lists like

   [1,[2,[3,[4,[5,6,7]]]],8,9]

This post covers three different ways to handle the problem:

  1. "Cheating" by using •BQN to do the heavy lifting
  2. Writing a conventional recursive descent parser
  3. Writing an array-style parser

We'll also do some simple benchmarking to compare the three approaches.

The Data

We'll be using my advent of code input file to test the different approaches on. Here's the first six lines: