Created
September 2, 2014 02:06
-
-
Save iamdustan/83d8f3c8759e31eb0f74 to your computer and use it in GitHub Desktop.
codeeval simple-sorting
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 worky | |
(:gen-class) | |
(:use clojure.pprint)) | |
(defn process [line] | |
(if (not= "" line) | |
(sort (vec (map read-string (re-seq #"-?[\d.]+" line)))))) | |
(defn fmt [line] | |
(clojure.string/join | |
" " | |
(map (fn [n] (format "%.3f" n)) | |
line))) | |
(defn -main [args] | |
(with-open [rdr (clojure.java.io/reader args)] | |
(doseq [line (line-seq rdr)] | |
(println (fmt (process line)))))) | |
(apply -main *command-line-args*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment