From: Ben Harris Date: Mon, 13 May 2024 13:33:52 +0000 (+0100) Subject: 13a: most of the list parser done X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=47aabae615bb93d1bbb6d7532148d65232d2f2c9;p=aoc-2022.git 13a: most of the list parser done --- diff --git a/13/13a.bqn b/13/13a.bqn new file mode 100644 index 0000000..6a1c6b1 --- /dev/null +++ b/13/13a.bqn @@ -0,0 +1,20 @@ +Split←{ + blocknums ← +`𝕨 + # Set entries in blocknums to -1 when they correspond with delimiters. + blocknums ↩ (¯1¨)⌾(𝕨⊸/) blocknums + blocknums⊔𝕩 +} + +Prep←{ + {•Show 𝕩 ⋄ •Show ParseVal 𝕩}¨¨(""⊸≡¨𝕩)Split𝕩 +} + +ParseList←{𝕊in: + in↩1↓¯1↓in + depth←+`('['=in)-(']'=in) + ParseVal¨ ((','=in)∧(depth=0)) Split in +} + +ParseVal←{'['=⊑𝕩}◶⟨•ParseFloat,ParseList⟩ + +•Show Prep •file.Lines ⊑•args