获取';试图调用未绑定的fn';在clojure命令行应用程序中

获取';试图调用未绑定的fn';在clojure命令行应用程序中,clojure,functional-programming,jvm,leiningen,cider,Clojure,Functional Programming,Jvm,Leiningen,Cider,我有下面的代码,当我在苹果酒中一步一步地运行它时,它可以工作,但是当我在命令行上直接运行它时,我得到以下错误: Exception in thread "main" java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure-todo.todo/execute-todo-cmd, compiling:(/private/var/folders/d_/b8gmsvl16sgdg70m15gx20l40000gn

我有下面的代码,当我在苹果酒中一步一步地运行它时,它可以工作,但是当我在命令行上直接运行它时,我得到以下错误:

Exception in thread "main" java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure-todo.todo/execute-todo-cmd, compiling:(/private/var/folders/d_/b8gmsvl16sgdg70m15gx20l40000gn/T/form-init6080372317525706515.clj:1:125)
        at clojure.lang.Compiler.load(Compiler.java:7391)
        at clojure.lang.Compiler.loadFile(Compiler.java:7317)
        at clojure.main$load_script.invokeStatic(main.clj:275)
        at clojure.main$init_opt.invokeStatic(main.clj:277)
        at clojure.main$init_opt.invoke(main.clj:277)
        at clojure.main$initialize.invokeStatic(main.clj:308)
        at clojure.main$null_opt.invokeStatic(main.clj:342)
        at clojure.main$null_opt.invoke(main.clj:339)
        at clojure.main$main.invokeStatic(main.clj:421)
        at clojure.main$main.doInvoke(main.clj:384)
        at clojure.lang.RestFn.invoke(RestFn.java:421)
        at clojure.lang.Var.invoke(Var.java:383)
        at clojure.lang.AFn.applyToHelper(AFn.java:156)
        at clojure.lang.Var.applyTo(Var.java:700)
        at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure-todo.todo/execute-todo-cmd
这是代码。我猜这是一个名称空间错误,但我很困惑,如果它在苹果酒中工作,它怎么可能是一个名称空间问题

 (ns clojure-todo.todo
  (:gen-class))

    ///// Other Code here
(defn print-msg-list [list]
  (doseq [item list] (print-msg item)))

(defn create-todo [todo-string] (hash-map :todo-content todo-string :checked false))

(defn list-todos [todos]
  (doseq [single-todo todos]
    (do
      (print (get single-todo :todo-content))
      (let [is-checked (get single-todo :checked)]
        (if is-checked
          (print-msg :is-checked)
          (print-msg :is-unchecked))))))

(defn add-todo []
  (do
    (print-msg :add-todo-message)
    (let [todo-string (read-line) the-todo-created (create-todo todo-string)]
        (def the-todos (conj the-todos the-todo-created))
        (list-todos the-todos)))

(def todo-fns {"1" add-todo "2" delete-todo "3" list-todos "4" check-todo})

(defn execute-todo-cmd [command]
  (get todo-fns command nil)))

(defn take-todo-command [backup-fn]
  (let [command (read-line)]
      (if (= command "q")
        (print-msg :goodbye)
        (let [todo-fn (execute-todo-cmd command)]
          (if todo-fn
            (todo-fn)
            (do
              (print-msg :sorry)
              (print-msg :border)
              (backup-fn)))))))

(defn run-app []
  (do
    (print-msg :welcome)
    (print-msg-list '(:add-todo :list-todos :delete-todo :check-todo :quit))
    ;; The take-todo-command fn takes a backup in case the user types in
    ;; a command that's not supported by the application. In this case we just
    ;; want the app to restart
    (take-todo-command run-app)))

这只是在addtodo中缺少一个close paren,在executetodo cmd中还有一个额外的close paren。因此,在运行addtodo之前,executetodo cmd不存在,这就是为什么它会产生未绑定的fn错误

“添加待办事项”中缺少关闭参数。在executetodo cmd中有一个额外的关闭参数。这意味着在运行addtodo之前,executetodo cmd不存在,这就是为什么会出现unbound fn error.Agh!多么愚蠢的错误啊。如果您添加您的答案,我将接受。@OceansOnPluto强烈建议使用一个编辑器为您排序(自动平衡参数、光标悬停时与参数匹配的高亮度等)。