chiark / gitweb /
14a: map constructed
authorBen Harris <bjh21@bjh21.me.uk>
Tue, 14 May 2024 12:16:38 +0000 (13:16 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Tue, 14 May 2024 12:16:38 +0000 (13:16 +0100)
14/14a.bqn

index 3d5a3506abe2afbbee88aecf0db992a4c6f796eb..407a672ed7e621687486a751de037a2cf18d98d1 100644 (file)
@@ -1,2 +1,35 @@
+Split←{
+  blocknums ← +`𝕨
+  # Set entries in blocknums to -1 when they correspond with delimiters.
+  blocknums ↩ (¯1¨)⌾(𝕨⊸/) blocknums
+  blocknums⊔𝕩
+}
+
 _and_and_←{𝕨𝔽◶⟨0,𝕘⟩𝕩}
 _or_or_  ←{𝕨𝔽◶⟨𝕘,1⟩𝕩}
+
+Prep←{𝕊 lines:
+  {
+    fields←(⊑∘∊⟜" ->"¨𝕩) Split 𝕩 # Ewww
+    fields↩(0=4|↕≠fields)/fields
+    {
+      •ParseFloat¨(','=𝕩)Split𝕩
+    }¨fields
+  }¨lines
+}
+
+RectIndices←{
+  i←>𝕨⋈𝕩
+  (⌊˝i)⊸+¨⥊↕(1+⌈˝i)-(⌊˝i)
+}
+
+Plot←{
+  # Assume all co-ordinates are positive.
+  map←(1+⌈˝>∾𝕩)⥊0
+  {𝕊⟨from,to⟩:
+    map ↩ 1¨⌾((from RectIndices to)⊸⊑) map
+  }˘∾2↕¨𝕩
+  map⊏".#"
+}
+
+•Show Plot Prep •file.Lines ⊑•args