Skip to content

Commit

Permalink
Added exercise 'singleton?'.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jani Rahkola committed Oct 21, 2012
1 parent 3a590e4 commit f1c6017
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/recursion.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
(defn product [coll]
:-)

(defn singleton? [coll]
:-)

(defn last-element [coll]
:-)

Expand Down
6 changes: 6 additions & 0 deletions test/recursion_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f1c6017

Please sign in to comment.