From f1c6017de24ad5fe432ee63629f2f4b7c5da47fd Mon Sep 17 00:00:00 2001 From: Jani Rahkola Date: Mon, 22 Oct 2012 00:20:58 +0300 Subject: [PATCH] Added exercise 'singleton?'. --- src/recursion.clj | 3 +++ test/recursion_test.clj | 6 ++++++ 2 files changed, 9 insertions(+) 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