From 84de7504361e129acb96452a3f06bb1193304103 Mon Sep 17 00:00:00 2001 From: sterni Date: Fri, 7 Feb 2025 15:28:57 +0100 Subject: [PATCH] =?UTF-8?q?refactor(sterni/bl=C3=ABrg):=20try=20to=20impro?= =?UTF-8?q?ve=20code=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Reduce visual noise, e.g. parens where it hurts readability. - Separate parts of trains visually where it helps readability. - Reduce amount of unnecessarily pointfree code. Change-Id: Ie0ef03af7d344863a81bf0557b90a4dfb7974e84 Reviewed-on: https://cl.tvl.fyi/c/depot/+/13126 Autosubmit: sterni Reviewed-by: sterni Tested-by: BuildkiteCI --- users/sterni/blërg/blërg.bqn | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/users/sterni/blërg/blërg.bqn b/users/sterni/blërg/blërg.bqn index b516a0250..ad10a5950 100755 --- a/users/sterni/blërg/blërg.bqn +++ b/users/sterni/blërg/blërg.bqn @@ -11,20 +11,20 @@ MkDirP ← •file.CreateDir⍟(¬•file.Exists) -AsciiDown ← ('A'-'a')⊸(⊢-×⟜('A'⊸≤∧≤⟜'Z')) -Slugify ← '-'⊸⊣⍟(¬(('A'⊸≤∧'z'⊸≥)∨<⊸(⊑∊)⟜"-_0123456789"))¨ AsciiDown +AsciiDown ← ⊢ - ('A'-'a')⊸×⟜('A'⊸≤∧≤⟜'Z') +Slugify ← '-'⊸⊣⍟(('A'⊸≤ ∧ ≤⟜'z') ¬∘∨ "-_0123456789"⊸(⊑∊˜)⟜<)¨ AsciiDown DropPrefix ← {𝕩(≠/⊣)𝕨↑˜≠𝕩} -StripLeft ← ((¬ ∧`∘=)/⊢) +StripLeft ← (¬ ∧`∘=)/⊢ StripRight ← ⌽ StripLeft⟜⌽ _join ← {(∾⟜(𝕗⊸∾))´𝕩;𝕨∾𝕗∾𝕩} nl ← @+10 -SplitChar ← ((=(¯1˙⍟⊣)¨+`∘=)⊔⊢) +SplitChar ← (= (¯1˙⍟⊣)¨ +`∘=)⊔⊢ Lines ← nl⊸SplitChar -ReadPosInt ← {(𝕨⊸×+⊣)´∘⌽-⟜'0'𝕩} # ty leah2 +ReadPosInt ← {(𝕨⊸×+⊣)´ ⌽'0'-˜𝕩} # ty leah2 ReadPosDec ← 10⊸ReadPosInt Chomp ← {⟨nl⟩≡¯1↑𝕩? ¯1↓𝕩; 𝕩} @@ -42,7 +42,7 @@ LR ← Lines∘R GetEnv ← {R "importas"‿"env"‿𝕩‿"printf"‿"%s"‿"$env"} RelPath ← •wdpath⊸•file.At -SplitExt ← (∊⌾⌽(∨`∘∧+¯2⊸×∘∧)=⟜'.')⊔⊢ +SplitExt ← (∊⌾⌽ (∨`∘∧ + ¯2⊸×∘∧) =⟜'.')⊔⊢ # 3p dependencies @@ -81,16 +81,16 @@ MailNotesBackend ← {𝕊 config: # Git Backend converters ← ⍉>⟨ -# TODO(sterni): avoid cat -⟨"html", ⋈"cat"⟩, -⟨"md", "lowdown"‿"-T"‿"html"‿"--html-no-skiphtml"‿"--html-no-escapehtml"‿"--html-callout-mdn"⟩, -# TODO(sterni): use emacs -⟨"org", "pandoc"‿"-f"‿"org"‿"-t"‿"html5"⟩, + # TODO(sterni): avoid cat + ⟨"html", ⋈"cat"⟩, + ⟨"md", "lowdown"‿"-T"‿"html"‿"--html-no-skiphtml"‿"--html-no-escapehtml"‿"--html-callout-mdn"⟩, + # TODO(sterni): use emacs + ⟨"org", "pandoc"‿"-f"‿"org"‿"-t"‿"html5"⟩, ⟩ # TODO(sterni): don't assemble blocks in this ad hoc fashion # TODO(sterni): pipefail -PipelineCmd ← {"pipeline"⋈⊸∾(' '⊸∾¨𝕨)∾""⋈⊸∾𝕩} +PipelineCmd ← {⟨"pipeline"⟩∾(' '⊸∾¨𝕨)∾⟨""⟩∾𝕩} GitBackend ← {𝕊 config: repo ← RelPath •file.At config j.ObjGet "repository" @@ -155,14 +155,14 @@ config ← { raw ← j.Parse •FChars configFile [bns,bcs] ← raw j.ObjGet "backends" - bcs ↩ bcs ∾˘⟜{2‿1⊸⥊"name"‿𝕩}¨ bns - bts ← (j.ObjGet⟜"type")˜¨ bcs + bcs ↩ bcs ∾˘⟜{2‿1⥊"name"‿𝕩}¨ bns + bts ← j.ObjGet⟜"type"¨ bcs backends ⇐ bcs {𝕏 𝕨}¨ backends⊸j.ObjGet¨ bts title ⇐ raw j.ObjGet "title" } -entries ← (<"time") ((⍒∘(•ns.Get˜¨))⊏⊢) ∾{𝕩.Entries @}¨ config.backends +entries ← ((⍒ •ns.Get⟜"time"¨)⊏⊢) ∾{𝕩.Entries @}¨ config.backends "All entry IDs must be unique"!(≠=≠∘⍷) •ns.Get⟜"id"¨ entries MkDirP outDir