chiark / gitweb /
A bit more Split fettling in 04
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 4 May 2024 12:02:59 +0000 (13:02 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 4 May 2024 12:02:59 +0000 (13:02 +0100)
It was silly to have an operator that immediately called its operand on
its argument and did nothing else with the operand.  Better to have a
function that takes the output of the operand as its left argument.
That avoids the confusion I had over whether the operator should take a
function that acts on a single element or on the whole list: it now
takes neither.

This doesn't even make calling the function any harder. It just changes
F _split x into F⊸Split x.

04/04a.bqn
04/04b.bqn

index 4e378b4e9f6ca0502fe801dc87aba15e0a8ef4d3..a278ab9b23ea8bb8b415ecf0e90e00421451169b 100644 (file)
@@ -1,12 +1,11 @@
-_split←{
-  delims←𝔽𝕩
-  blocknums ← +`delims
-  # Set entries in blocknums to -1 when they correspond with delims.
-  blocknums ↩ (¯1¨)⌾(delims⊸/) blocknums
+Split←{
+  blocknums ← +`𝕨
+  # Set entries in blocknums to -1 when they correspond with delimiters.
+  blocknums ↩ (¯1¨)⌾(𝕨⊸/) blocknums
   blocknums⊔𝕩
 }
 
-Prep←{⍉>•ParseFloat¨¨{𝕩∊",-"}_split¨𝕩}
+Prep←{⍉>•ParseFloat¨¨{𝕩∊",-"}⊸Split¨𝕩}
 
 Main←{𝕊[x0,x1,y0,y1]:
   +´((x0≤y0)∧(x1≥y1))∨((y0≤x0)∧(y1≥x1))
index 048a6dc07028c54b6953ed34127ae3288e3ca70f..a89e0e97af6e8c58de0ccaec3234bb4aa9d99520 100644 (file)
@@ -1,12 +1,11 @@
-_split←{
-  delims←𝔽𝕩
-  blocknums ← +`delims
-  # Set entries in blocknums to -1 when they correspond with delims.
-  blocknums ↩ (¯1¨)⌾(delims⊸/) blocknums
+Split←{
+  blocknums ← +`𝕨
+  # Set entries in blocknums to -1 when they correspond with delimiters.
+  blocknums ↩ (¯1¨)⌾(𝕨⊸/) blocknums
   blocknums⊔𝕩
 }
 
-Prep←{⍉>•ParseFloat¨¨{𝕩∊",-"}_split¨𝕩}
+Prep←{⍉>•ParseFloat¨¨{𝕩∊",-"}⊸Split¨𝕩}
 
 Main←{𝕊[x0,x1,y0,y1]:
   +´((x0≤y1)∧(x1≥y0))∨((y0≤x1)∧(y1≥x0))