aboutsummaryrefslogtreecommitdiff
path: root/md.bqn
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-08-17 10:20:36 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-08-17 10:20:36 -0400
commit3cccac26dc804704446cd88676dc583f997252fd (patch)
tree97ad0827866e7290740ac0e3ab0a245174421c02 /md.bqn
parentf35eb238324d446c383a36828d7154001a2badd5 (diff)
Index-based is better than mask-based tracing (e.g. for strings and comments)
Diffstat (limited to 'md.bqn')
-rw-r--r--md.bqn12
1 files changed, 6 insertions, 6 deletions
diff --git a/md.bqn b/md.bqn
index 5576ba12..3c461d38 100644
--- a/md.bqn
+++ b/md.bqn
@@ -87,23 +87,23 @@ PrecedesGroup ← {
Trace ← {
# 𝕨 is a list with one index for each possible start, giving a later
# start that is known to be enabled if that one is.
- # 𝕩 is a mask of all starts known to be enabled.
+ # 𝕩 is a list of all starts known to be enabled.
# A "stop" position that follows all expressions tells when to stop.
# At each step the distance from a start to its successor in 𝕨 is
# doubled, so the maximum number of steps is about 2⋆⁼≠𝕩.
En ← {
- 𝕩 ↩ 1¨⌾((𝕩/𝕨)⊸⊏)𝕩 # Starts following from an enabled one are enabled
+ 𝕩 ∾↩ 𝕩⊏𝕨 # Add starts following from an enabled one
𝕨 ↩ ⊏˜ 𝕨 # Double the number of steps in 𝕨
𝕨 En 𝕩 # Repeat
- }⍟{0=¯1⊑𝕩} # until the stop is enabled
+ }⍟{end≠¯1⊑𝕩} # until the end is reached
g ← ⍋𝕨 # Order expressions by starting index
start ← g⊏𝕨
end ← g⊏𝕩
next ← start ⍋ end # An expression's successor starts after it ends
- next ∾↩ ≠next # The stop node is its own successor
- enabled ← ¯1 ↓ next En (≠next)↑1 # Search and remove the stop
- enabled / start≍˘end # List of enabled starts and ends
+ next ∾↩ end←≠next # The stop node is its own successor
+ enabled ← end⊸>⊸/ next En ⋈0 # Search, then remove stops
+ enabled ⊏ start≍˘end # List of enabled starts and ends
}
# Join lines with newline characters. Include a trailing newline.