From a730fc5426804996df4b00f312a470c9b2915e26 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sat, 4 May 2024 13:02:59 +0100 Subject: [PATCH] A bit more Split fettling in 04 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 11 +++++------ 04/04b.bqn | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/04/04a.bqn b/04/04a.bqn index 4e378b4..a278ab9 100644 --- a/04/04a.bqn +++ b/04/04a.bqn @@ -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)) diff --git a/04/04b.bqn b/04/04b.bqn index 048a6dc..a89e0e9 100644 --- a/04/04b.bqn +++ b/04/04b.bqn @@ -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)) -- 2.30.2