diff --git a/src/ex/q029.clj b/src/ex/q029.clj new file mode 100644 index 0000000..1cbdbba --- /dev/null +++ b/src/ex/q029.clj @@ -0,0 +1,9 @@ +;; https://4clojure.oxal.org/#/problem/029 + +(ns ex.q029) + +(defn ans + "Problem 29, Get the Caps. (return a new string containing only the capital letters)" + [s] + (let [caps (set "ABCDEFGHIJKLMNOPQRSTUVWXYZ")] + (apply str (filter #(contains? caps %) s)))) \ No newline at end of file diff --git a/test/ex/q029_test.clj b/test/ex/q029_test.clj new file mode 100644 index 0000000..2c15b89 --- /dev/null +++ b/test/ex/q029_test.clj @@ -0,0 +1,11 @@ +;; https://4clojure.oxal.org/#/problem/029 + +(ns ex.q029-test + (:require [clojure.test :as t] + [ex.q029 :as sut])) + +(t/deftest test-q29 + (t/testing "Problem 29, Get the Caps" + (t/is (= "HLOWRD" (sut/ans "HeLlO, WoRlD!"))) + (t/is (empty? (sut/ans "nothing"))) + (t/is (= "AZ" (sut/ans "$#A(*&987Zf"))))) \ No newline at end of file