我只是学习“衣物”,在把我的法典翻译成不同档案方面遇到麻烦。
我将这一错误从 app子中删除。
Exception in thread "main" java.lang.Exception: Unable to resolve symbol: -run-application in this context
似乎发现名称空间被罚款,但后来却看不见瓦雷斯受到约束...... 如何解决这一问题的想法?
我的守则如下:
附录二
(ns src/apprunner
(:use src/functions))
(def input-files [(resource-path "a.txt") (resource-path "b.txt") (resource-path "c.txt")])
(def output-file (resource-path "output.txt"))
(defn run-application []
(sort-files input-files output-file))
(run-application)
任用 -
(ns src/functions
(:use clojure.contrib.duck-streams))
(defn flatten [x]
(let [s? #(instance? clojure.lang.Sequential %)]
(filter
(complement s?)
(tree-seq s? seq x))))
(defn resource-path [file]
(str "C:/Users/Alex and Paula/Documents/SoftwareProjects/MyClojureApp/resources/" file))
(defn split2 [str delim]
(seq (.split str delim)))
(defstruct person :first-name :last-name)
(defn read-file-content [file]
(apply str
(interpose "
" (read-lines file))))
(defn person-from-line [line]
(let [sections (split2 line " ")]
(struct person (first sections) (second sections))))
(defn formatted-for-display [person]
(str (:first-name person) (.toUpperCase " ") (:last-name person)))
(defn sort-by-keys [struct-map keys]
(sort-by #(vec (map % [keys])) struct-map))
(defn formatted-output [persons output-number]
(let [heading (str "Output #" output-number "
")
sorted-persons-for-output (apply str (interpose "
" (map formatted-for-display (sort-by-keys persons (:first-name :last-name)))))]
(str heading sorted-persons-for-output)))
(defn read-persons-from [file]
(let [lines (read-lines file)]
(map person-from-line lines)))
(defn write-persons-to [file persons]
(dotimes [i 3]
(append-spit file (formatted-output persons (+ 1 i)))))
(defn sort-files [input-files output-file]
(let [persons (flatten (map read-persons-from input-files))]
(write-persons-to output-file persons)))