Created
July 22, 2014 20:05
-
-
Save adamschmideg/133f055ddb1359ed81d0 to your computer and use it in GitHub Desktop.
Numerals to roman Coding dojo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns romnum.core | |
(:require | |
[clojure.test :refer [is testing]])) | |
(def roman-digits [[1000 "M"] | |
[500 "D"] | |
[100 "C"] | |
[50 "L"] | |
; [40 "XL"] | |
[10 "X"] | |
[5 "V"] | |
[1 "I"]]) | |
(def roman-digits-map {1000 "M" 500 "D" 100 "C" 50 "L" 10 "X" 5 "V" 1 "I"}) | |
(defn num-to-roman | |
"Convert a number to roman" | |
[n] | |
(if (integer? n) "Not an integer" | |
"I" | |
) | |
) | |
;; tests | |
(testing "num-to-roman-test" | |
(is (= (num-to-roman 1) "I")) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment