Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Raynes
Created October 27, 2009 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raynes/219995 to your computer and use it in GitHub Desktop.
Save Raynes/219995 to your computer and use it in GitHub Desktop.
(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