Skip to content

Instantly share code, notes, and snippets.

@adolfont
Last active March 15, 2016 19:30
Show Gist options
  • Select an option

  • Save adolfont/a1b6e1ab4266b692d83a to your computer and use it in GitHub Desktop.

Select an option

Save adolfont/a1b6e1ab4266b692d83a to your computer and use it in GitHub Desktop.
(ns clojure.test.adolfo
(:use clojure.test))
; Documentation: http://philmaffetone.com/180-formula/
(defn maffetone-formula-max [age]
"Returns 180-age"
(- 180 age))
(deftest maffetone-formula-max-test
(is (= 160 (maffetone-formula-max 20))))
(defn maffetone-formula-min [age]
"Returns maffetone-formula minus 10"
(- (maffetone-formula-max age) 10))
(deftest maffetone-formula-min-test
(is (= 150 (maffetone-formula-min 20))))
(defn maffetone-formula-max [age & args]
"Returns 180-age or 180-age-10 if illness"
(if (contains? #{:illness :medication} (first args)) (- 170 age) (- 180 age)))
(deftest maffetone-formula-max-illness-test
(is (= 150 (maffetone-formula-max 20 :illness))))
(deftest maffetone-formula-max-medication-test
(is (= 150 (maffetone-formula-max 20 :medication))))
;; incomplete implementation
(defn maffetone-formula-max [age & args]
"Returns 180-age or 180-age-10 if illness"
(if (contains? #{:injury :regression} (first args)) (- 175 age) (- 180 age))
(if (contains? #{:illness :medication} (first args)) (- 170 age) (- 180 age))
)
(deftest maffetone-formula-max-injury-test
(is (= 155 (maffetone-formula-max 20 :injury))))
(deftest maffetone-formula-max-regression-test
(is (= 155 (maffetone-formula-max 20 :regression))))
(deftest maffetone-formula-max-sick-test
(is (= 155 (maffetone-formula-max 20 :sick))))
(deftest maffetone-formula-max-inconsistent-test
(is (= 155 (maffetone-formula-max 20 :inconsistent))))
(deftest maffetone-formula-max-returning-test
(is (= 155 (maffetone-formula-max 20 :returning))))
(deftest maffetone-formula-max-returning-test
(is (= 155 (maffetone-formula-max 20 :returning))))
(deftest maffetone-formula-max-injured-and-returning-test
(is (= 155 (maffetone-formula-max 20 :returning :injury))))
(deftest maffetone-formula-max-returning-and-injured-test
(is (= 155 (maffetone-formula-max 20 :injury :returning ))))
(run-tests)
;; Next Joe Friel Zone 1 Max http://home.trainingpeaks.com/blog/article/joe-friel-s-quick-guide-to-setting-zones
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment