diff --git a/src/recursion.clj b/src/recursion.clj index 44d39e9..5bbd715 100644 --- a/src/recursion.clj +++ b/src/recursion.clj @@ -3,6 +3,9 @@ (defn product [coll] :-) +(defn singleton? [coll] + :-) + (defn last-element [coll] :-) diff --git a/test/recursion_test.clj b/test/recursion_test.clj index eb6b54b..26355a1 100644 --- a/test/recursion_test.clj +++ b/test/recursion_test.clj @@ -9,6 +9,12 @@ (product [0 1 2]) => 0 (product #{2 3 4}) => 24) +(facts "singleton?" + (singleton? [1]) => true + (singleton? #{2}) => true + (singleton? []) => false + (singleton? [1 2 3]) => false) + (facts "last-element" (last-element []) => nil (last-element [1 2 3]) => 3