Skip to content

Instantly share code, notes, and snippets.

@timothyandrew
Created September 26, 2013 09:12
Show Gist options
  • Save timothyandrew/6711748 to your computer and use it in GitHub Desktop.
Save timothyandrew/6711748 to your computer and use it in GitHub Desktop.
(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