Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final version of booleans task #1634

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 47 additions & 23 deletions src/i_am_a_horse_in_the_land_of_booleans.clj
Original file line number Diff line number Diff line change
@@ -1,28 +1,52 @@
(ns i-am-a-horse-in-the-land-of-booleans
(:refer-clojure :exclude [boolean]))

(defn boolean [x]
":(")

(defn abs [x]
":(")

(defn divides? [divisor n]
":(")

(defn fizzbuzz [n]
":(")

(defn teen? [age]
":(")

(defn not-teen? [age]
":(")

(defn generic-doublificate [x]
":(")

(defn leap-year? [year]
":(")
(defn boolean [x]
(if (or (= x nil) (= x false))
false
true))

(defn abs [x]
(if (>= x 0)
x
(* x -1)))

(defn divides? [divisor n]
(if (== 0 (mod n divisor))
true
false))

(defn fizzbuzz [n]
(cond
(= true (and (divides? 3 n) (divides? 5 n))) "gotcha!"
(divides? 5 n) "buzz"
(divides? 3 n) "fizz"
:else ""
))

(defn teen? [age]
(if (and (> age 12) (< age 20))
true
false))

(defn not-teen? [age]
(if (not (teen? age))
true
false))

(defn generic-doublificate [x]
(cond
(number? x) (* 2 x)
(empty? x) nil
(or (list? x) (vector? x)) (* 2 (count x))
:else true
))

(defn leap-year? [year]
(cond
(divides? 400 year) true
(= (divides? 4 year) (divides? 100 year)) false
(divides? 4 year) true
))

; '_______'