From 47aabae615bb93d1bbb6d7532148d65232d2f2c9 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 13 May 2024 14:33:52 +0100 Subject: [PATCH] 13a: most of the list parser done --- 13/13a.bqn | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 13/13a.bqn 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 -- 2.30.2