From 5d3abc4bf6f6609cb452c669ddec89279d601113 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 13 Jul 2022 17:11:46 -0400 Subject: Flatten computation of whether to show result --- md.bqn | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/md.bqn b/md.bqn index 44895ca2..55c11b9b 100644 --- a/md.bqn +++ b/md.bqn @@ -215,22 +215,23 @@ Markdown ← {filename𝕊𝕩: addRslt ← ∧´ ' ' = ∾ 4 (⌊⟜≠ ↑ ⊢)¨ 𝕩 r‿ri ← { ¬addRslt ? ⋈˜⟨⟩ ; - # Find the top-level separators sep + # Top-level separators are those not inside brackets m ← NotCommentOrString code depth ← +` m × "(){}⟨⟩[]" (⊣(≠⊸>×·¬⊸-2|⊢)⊐) code - sep ← (0=depth) ∧ m ∧ code∊"⋄,"∾lf - # Divide code - gr ← (1+´sl) ∾˜ (⊢-˜+`׬) sl←sep∧lf=code - # Don't show assignment results by default - ShowRslt ← { - c ← (¬ ∨`⌾⌽ 𝕨) / 𝕩 - g ← c∊"←↩" - (⊑g⊐1) (<⟜(≠g))◶⟨1,¬(" "∾∾idChars)∧´∘∊˜↑⟩ c - } + sep ← (0=depth) ∧ m ∧ code∊"⋄,"∾lf # Top-level separators + break ← sep∧lf=code # Mask of line breaks + # Grouping argument to split lines + ! 1=¯1⊑break + gr ← (⊢-˜+`׬) break + # Don't show assignment result + a ← code∊"←↩" ⋄ id ← code∊" "∾∾idChars + sa ← a ∧ ¬(¬sep) PrecedesGroup id∨a # Silent assignment + show ← ¬ break / sa PrecedesGroup ¬sa∨»sep + # Evaluate + E ← ⊣◶⟨"",(⥊∾⟜lf⎉1)∘Fmt⊢⟩⟜CodeExec ShowErr ← lf∾˜"span class='Error'"Html"Error: "∾(∧`lf⊸≠)⊸/⎊•Repr - E ← ShowRslt ⊣◶⟨"",(⥊∾⟜lf⎉1)∘Fmt∘⊢⟩ CodeExec∘⊢ - r ← (gr⊔sep) E⎊(ShowErr∘•CurrentError⊢)⍟(0<≠∘⊢)¨ gr⊔code - ⟨r, /sl∾1⟩ + r ← show E⎊(ShowErr∘•CurrentError⊢)⍟(0<≠∘⊢)¨ gr⊔code + ⟨r, /break⟩ } Link ← { -- cgit v1.2.3