chiark / gitweb /
13a: most of the list parser done
authorBen Harris <bjh21@bjh21.me.uk>
Mon, 13 May 2024 13:33:52 +0000 (14:33 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Mon, 13 May 2024 13:33:52 +0000 (14:33 +0100)
13/13a.bqn [new file with mode: 0644]

diff --git a/13/13a.bqn b/13/13a.bqn
new file mode 100644 (file)
index 0000000..6a1c6b1
--- /dev/null
@@ -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