From: Ben Harris Date: Tue, 7 May 2024 12:36:44 +0000 (+0100) Subject: 07a: got a list of files with full paths X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=13187a51471e2d73282646e959701020039288a2;p=aoc-2022.git 07a: got a list of files with full paths --- diff --git a/07/07a.bqn b/07/07a.bqn index 7d09dca..025e2cf 100644 --- a/07/07a.bqn +++ b/07/07a.bqn @@ -5,12 +5,25 @@ Split←{ blocknums⊔𝕩 } +Prep←{ + 1↓(+`{"$ "≡2↑𝕩}¨𝕩)⊔𝕩 +} + FS←{𝕤 cwd←⟨⟩ + nothing←⟨0,2⟩⥊⟨⟩ # 0 by 23 array, to return from "cd" Exec⇐{ - 𝕊⟨"cd", "/"⟩: cwd↩⟨⟩; - 𝕊⟨"cd", ".."⟩: cwd 1⊸↓↩; - 𝕊⟨"cd", dir⟩: cwd ⟨dir⟩⊸∾↩ + ⟨⟩𝕊⟨"cd", "/"⟩: cwd↩⟨⟩, nothing; + ⟨⟩𝕊⟨"cd", ".."⟩: cwd 1⊸↓↩, nothing; + ⟨⟩𝕊⟨"cd", dir⟩: cwd ⟨dir⟩⊸∾↩, nothing; + input𝕊⟨"ls"⟩: >{𝕊⟨size,name⟩:⟨size,⟨name⟩∾cwd⟩}∘{(' '=𝕩)Split𝕩}¨input } - Cmd⇐{Exec (' '=𝕩)Split𝕩} + Cmd⇐{𝕨 Exec 1↓(' '=𝕩)Split𝕩} } + +Main←{ + dev←FS @ + files←∾{(1↓𝕩)dev.Cmd(⊑𝕩)}¨𝕩 +} + +•Show Main Prep •file.Lines ⊑•args