Created
September 26, 2013 09:12
-
-
Save timothyandrew/6711748 to your computer and use it in GitHub Desktop.
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 antonyms.core | |
(:gen-class) | |
(:require [clj-http.client :as client])) | |
(use 'clojure.java.io) | |
(defn process-file | |
"Call func once for with each line in filename" | |
[filename func] | |
(with-open [rdr (reader filename)] | |
(doseq [line (line-seq rdr)] | |
(func line)))) | |
(defn parse-line [line] | |
(map clojure.string/trim (clojure.string/split line #"[-]"))) | |
(defn check-antonym | |
[line] | |
(let [[word antonym] (parse-line line) | |
word-length (count word) | |
antonym-length (count antonym)] | |
(if (= word-length antonym-length) | |
(println (str word " - " antonym))))) | |
(defn -main | |
[filename] | |
(process-file filename check-antonym)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment