aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Sucan <jan@jansucan.com>2023-09-20 15:36:14 +0200
committerJan Sucan <jan@jansucan.com>2023-09-20 15:36:14 +0200
commit246ae29d6d8bcca40e94263220d6ae21214d30ea (patch)
treeef4d069efbdaabb764114beef18f2adfdc67b131
parent360121c45b585839101523638589462cf1c3da6e (diff)
9_b_1: Add solution
-rw-r--r--README.md2
-rw-r--r--ch09/9_b_1.hs22
-rw-r--r--ch09/test-9_b_1/A0
-rw-r--r--ch09/test-9_b_1/B0
-rw-r--r--ch09/test-9_b_1/dirC/E0
-rw-r--r--ch09/test-9_b_1/dirC/F0
-rw-r--r--ch09/test-9_b_1/dirD/G0
-rw-r--r--ch09/test-9_b_1/dirD/H0
8 files changed, 23 insertions, 1 deletions
diff --git a/README.md b/README.md
index 43d6d3c..6c0f579 100644
--- a/README.md
+++ b/README.md
@@ -125,7 +125,7 @@ are prefixed with 'Module_'.
| 8_c_2 | yes | | |
| **_8_d_1_** | yes | 212 | |
| **_9_a_1_** | yes | 221 | 9. I/O case study: a library for searching the filesystem |
-| **_9_b_1_** | | 228 | |
+| **_9_b_1_** | yes | 228 | |
| 9_b_2 | | | |
| 9_b_3 | | | |
| 9_b_4 | | | |
diff --git a/ch09/9_b_1.hs b/ch09/9_b_1.hs
new file mode 100644
index 0000000..165c609
--- /dev/null
+++ b/ch09/9_b_1.hs
@@ -0,0 +1,22 @@
+-- What you should pass to 'traverse' to traverse a directory tree in reverse
+-- alphabetic order?
+
+-- ghci> :l ControlledVisit.hs
+-- [1 of 1] Compiling ControlledVisit ( ControlledVisit.hs, interpreted )
+-- Ok, one module loaded.
+
+-- Import Data.List module for getting the 'sort' function
+-- ghci> :m +Data.List
+
+-- Output of the following command is manually shortened and formatted for clarity
+-- traverse' (reverse.sort) "test-9_b_1"
+-- ghci> traverse' (reverse.sort) "test-9_b_1"
+-- [Info {infoPath = "test-9_b_1/dirD/H", ...},
+-- Info {infoPath = "test-9_b_1/dirD/G", ...},
+-- Info {infoPath = "test-9_b_1/dirD", ...},
+-- Info {infoPath = "test-9_b_1/dirC/F", ...},
+-- Info {infoPath = "test-9_b_1/dirC/E", ...},
+-- Info {infoPath = "test-9_b_1/dirC", ...},
+-- Info {infoPath = "test-9_b_1/B", ...},
+-- Info {infoPath = "test-9_b_1/A", ...},
+-- Info {infoPath = "test-9_b_1", ...}]
diff --git a/ch09/test-9_b_1/A b/ch09/test-9_b_1/A
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ch09/test-9_b_1/A
diff --git a/ch09/test-9_b_1/B b/ch09/test-9_b_1/B
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ch09/test-9_b_1/B
diff --git a/ch09/test-9_b_1/dirC/E b/ch09/test-9_b_1/dirC/E
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ch09/test-9_b_1/dirC/E
diff --git a/ch09/test-9_b_1/dirC/F b/ch09/test-9_b_1/dirC/F
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ch09/test-9_b_1/dirC/F
diff --git a/ch09/test-9_b_1/dirD/G b/ch09/test-9_b_1/dirD/G
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ch09/test-9_b_1/dirD/G
diff --git a/ch09/test-9_b_1/dirD/H b/ch09/test-9_b_1/dirD/H
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ch09/test-9_b_1/dirD/H