Skip to content

Commit

Permalink
Refactor code to be more expressive
Browse files Browse the repository at this point in the history
Replace imperative definitions such as (if (= 0 count(args))) to
(if (empty? args)). This way, the code seems more elegant and clean,
since is easier to understand.
  • Loading branch information
medeiros committed Oct 1, 2019
1 parent de2e252 commit 9a0420f
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/a1_positional_style_converter/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,11 @@
(clojure.string/join (map char (map #(+ % 65) (cons x l))))
(recur (dec (int (/ x 26))) (cons (rem x 26) l)))))


(defn -main
"I don't do a whole lot ... yet."
[& args]

(if (= 0 (count args))
(defn -main [& args]
(if (empty? args)
(println "params: [pos|a1] [pos value|a1 value]")
(do
(let [x (nth args 0)]
(case x
"pos" (println (convert-positional-to-a1 (Integer/parseInt (nth args 1))))
"a1" (println (convert-a1-to-positional (nth args 1))))))))


(let [type (nth args 0)
param (nth args 1)]
(case type
"pos" (println (convert-positional-to-a1 (Integer/parseInt param)))
"a1" (println (convert-a1-to-positional param))))))

0 comments on commit 9a0420f

Please sign in to comment.