chiark / gitweb /
07a trivial CLI that can cd
authorBen Harris <bjh21@bjh21.me.uk>
Tue, 7 May 2024 08:14:37 +0000 (09:14 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Tue, 7 May 2024 08:22:19 +0000 (09:22 +0100)
07/07a.bqn [new file with mode: 0644]

diff --git a/07/07a.bqn b/07/07a.bqn
new file mode 100644 (file)
index 0000000..7d09dca
--- /dev/null
@@ -0,0 +1,16 @@
+Split←{
+  blocknums ← +`𝕨
+  # Set entries in blocknums to -1 when they correspond with delimiters.
+  blocknums ↩ (¯1¨)⌾(𝕨⊸/) blocknums
+  blocknums⊔𝕩
+}
+
+FS←{𝕤
+  cwd←⟨⟩
+  Exec⇐{
+    𝕊⟨"cd", "/"⟩:  cwd↩⟨⟩;
+    𝕊⟨"cd", ".."⟩: cwd 1⊸↓↩;
+    𝕊⟨"cd", dir⟩:  cwd ⟨dir⟩⊸∾↩
+  }
+  Cmd⇐{Exec (' '=𝕩)Split𝕩}
+}