diff --git a/.gitignore b/.gitignore index ee508f76..308d89a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea /target /lib /classes @@ -8,3 +9,5 @@ pom.xml .lein-deps-sum .lein-failures .lein-plugins +/i-am-a-horse-in-the-land-of-booleans.iml +/.lein-repl-history diff --git a/.travis.yml b/.travis.yml index 455f3c0e..721fea2b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: clojure -lein: lein2 -script: lein2 midje :config .midje-grading-config.clj +lein: lein +script: lein midje :config .midje-grading-config.clj jdk: - - openjdk7 + - openjdk11 notifications: email: false webhooks: http://polar-hollows-8825.herokuapp.com/notifications diff --git a/project.clj b/project.clj index 4991997b..6f9d1980 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,5 @@ (defproject i-am-a-horse-in-the-land-of-booleans "1.0.0-SNAPSHOT" - :dependencies [[org.clojure/clojure "1.5.1"] + :dependencies [[org.clojure/clojure "1.10.0"] [iloveponies.tests/i-am-a-horse-in-the-land-of-booleans "0.1.0-SNAPSHOT"]] - :profiles {:dev {:plugins [[lein-midje "3.1.1"]]}}) + :profiles {:dev {:dependencies [[midje "1.9.5" :exclusions [org.clojure/clojure]]] + :plugins [[lein-midje "3.2.1"]]}}) diff --git a/src/i_am_a_horse_in_the_land_of_booleans.clj b/src/i_am_a_horse_in_the_land_of_booleans.clj index 66a18e7a..e9c69992 100644 --- a/src/i_am_a_horse_in_the_land_of_booleans.clj +++ b/src/i_am_a_horse_in_the_land_of_booleans.clj @@ -2,27 +2,40 @@ (:refer-clojure :exclude [boolean])) (defn boolean [x] - ":(") + (if (or (= x nil) (= x false)) false true)) (defn abs [x] - ":(") + (if (neg? x) (* x -1) x)) (defn divides? [divisor n] - ":(") + (== (mod n divisor) 0)) (defn fizzbuzz [n] - ":(") + (cond + (and (divides? 3 n) (divides? 5 n)) "gotcha!" + (divides? 3 n) "fizz" + (divides? 5 n) "buzz" + :else "")) + (defn teen? [age] - ":(") + (if (and (>= age 13) (<= age 19)) true false)) (defn not-teen? [age] - ":(") + (not (teen? age))) (defn generic-doublificate [x] - ":(") + (cond + (number? x) (* 2 x) + (empty? x) nil + (or (list? x) (vector? x)) (* (count x) 2) + :else true)) (defn leap-year? [year] - ":(") + (cond + (divides? 400 year) true + (and (divides? 4 year) (not (divides? 100 year))) true + :else false + )) ; '_______'