Clojure中的矢量预期?

时间:2015-03-03 20:10:57

标签: clojure leiningen

目前我收到此错误。

Parameter declaration symmetrize-body-parts should be a vector,
compiling:(braveclojure/core.clj:41:49)

我的core.clj文件

(ns braveclojure.core
  (:gen-class))

(def asym-hobbit-body-parts [{:name "head" :size 3}
                            {:name "left-eye" :size 1}
                            {:name "left-ear" :size 1}
                            {:name "mouth" :size 1}
                            {:name "nose" :size 1}
                            {:name "neck" :size 2}
                            {:name "left-shoulder" :size 3}
                            {:name "left-upper-arm" :size 3}
                            {:name "chest" :size 10}
                            {:name "back" :size 10}
                            {:name "left-forearm" :size 3}
                            {:name "abdomen" :size 6}
                            {:name "left-kidney" :size 1}
                            {:name "left-hand" :size 2}
                            {:name "left-knee" :size 2}
                            {:name "left-thigh" :size 4}
                            {:name "left-lower-leg" :size 3}
                            {:name "left-achilles" :size 1}
                            {:name "left-foot" :size 2}])

(defn needs-matching-part? [part]
    (re-find #"^left-" (:name part)))

(defn make-matching-part [part] {:name (clojure.string/replace (:name part) #"^left-" "right-")
     :size (:size part)})

(defn symmetrize-body-parts
    "Expects to see a seq of maps which have a :name and :size"
    [asym-body-parts]
    (loop [remaining-asym-parts asym-body-parts
           final-body-parts []]
           (if (empty? remaining-asym-parts)
             final-body-parts
             (let [[part & remaining] remaining-asym-parts
                    final-body-parts (conj final-body-parts part)]
                (if (needs-matching-part? part)
                    (recur remaining (conj final-body-parts (make-matching-part part)))
                    (recur remaining final-body-parts))))))

(defn -main (symmetrize-body-parts asym-hobbit-body-parts))

我在clojure app文件夹中使用lein run,但它引发了上述错误。我已经针对参数括号[]的位置切换了不同的东西,对称的对称 - 身体 - 部件函数定义从上到下都是docstring,但无济于事。这是怎么回事?

遵循here的教程。

1 个答案:

答案 0 :(得分:1)

尝试:

(defn -main [] 
  (symmetrize-body-parts asym-hobbit-body-parts))