Created
October 27, 2009 22:03
-
-
Save Raynes/219995 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 main.test | |
(:use clojure.contrib.str-utils | |
[clojure.contrib.duck-streams :only (spit)])) | |
(def input "Source.txt") | |
(def output "red.txt") | |
(defn remove-newlines | |
"Removes all \ns from the string." | |
[s] | |
(apply str (remove #(= % \newline) s))) | |
(defn get-nums [s] | |
(last (.split s ">"))) | |
(defn find-nums [s] | |
(let [parted (re-partition #"<font color=\"red\">[0-9]+" s)] | |
(map get-nums (map first (partition 1 2 (rest parted)))))) | |
(defn spit-nums [s] | |
(spit output (apply str (interpose "\n" s)))) | |
(defn main [] | |
(spit-nums (find-nums (remove-newlines (slurp input))))) | |
(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment