chiark / gitweb /
20a closer
authorBen Harris <bjh21@bjh21.me.uk>
Wed, 29 May 2024 12:59:41 +0000 (13:59 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Wed, 29 May 2024 12:59:41 +0000 (13:59 +0100)
Now the only problem is when a number lands precisely on the boundary.

20/20a.bqn

index 897c8ce4de51a0d74884d67e5febe063969cd525..be328ad9b9062794112e4b2bb4ea653f8a9d6ee4 100644 (file)
@@ -3,8 +3,16 @@ Prep←•ParseFloat¨
 Main←{ 𝕊 orig:
   •Show orig
   cur←orig
-  JumpFwd←{(1⊸⌽)⌾(((1+|𝕨)⊸↑)∘((⊑𝕩⊐𝕨)⊸⌽)) 𝕩}
-  Jump←{𝕨≥0 ? 𝕨 JumpFwd 𝕩; ⌽ 𝕨 JumpFwd ⌽𝕩}
+  #JumpFwd←{(1⊸⌽)⌾(((1+|𝕨)⊸↑)∘((⊑𝕩⊐𝕨)⊸⌽)) 𝕩}
+  #Jump←{𝕨≥0 ? 𝕨 JumpFwd 𝕩; ⌽ 𝕨 JumpFwd ⌽𝕩}
+  Jump←{
+    from ← ⊑𝕩⊐𝕨
+    to ← (¯1+≠𝕩)|𝕨+from
+    len ← to-from
+    •Show from‿to‿len
+    •Show ((1+|len)⊸↑∘((to⌊from)⊸↓)) 𝕩
+    ((×len)⊸⌽) ⌾ ((1+|len)⊸↑∘((to⌊from)⊸↓)) 𝕩
+  }
   {
     •Show cur ↩ 𝕩 Jump cur
   }¨orig