我試過你的源代碼,但省略了刷新。它工作沒有問題。你使用的是什麼版本的Clojure?我用Clojure 1.3試了下面的代碼。
(def command (atom 0))
(defn print-prompt []
(print "prompt> ")
)
(defn ask-for-input
[]
(print-prompt)
(let [x (str (read-line))]
(println (str "User input: " x))
(reset! command x)
))
編輯: 我改變了你的職責,我複製與測試之一,它現在獨立和雷音運行工作。您的原始示例中有(沖洗)。
(defn print-prompt []
(print "prompt> ")
(flush)
)
從我可以爭取,導致的println沖洗,打印不,你需要打印後沖水。
我在添加這些信息的情況下可能會有所幫助。我有一個名爲repl-test的Clojure項目。這是我的repl-test項目的core.clj文件頭。您已經發布的源文件包含其他一些功能,與您的文章無關。
(ns repl-test.core
(:gen-class)
(:use clojure.contrib.command-line)
(:require [clojure.contrib.string :as cstr])
(:require [clojure.contrib.trace :as ctr])
(:require [clojure.string :as sstr])
(:use clojure-csv.core))
這裏是project.clj文件:
(defproject repl-test "0.0.1-SNAPSHOT"
:description "TODO: add summary of your project"
:dependencies [[org.clojure/clojure "1.3.0"]
[org.clojure/clojure-contrib "1.2.0"]
[clojure-csv/clojure-csv "1.2.4"]
[org.clojure/tools.cli "0.1.0"]
[clj-http "0.1.3"]]
:aot [repl-test.core]
:main repl-test.core)
什麼命令?你會考慮編輯你的原始文章並把它放進去嗎?我試圖建立你的代碼並看看它。我想我知道它是什麼,但很高興看到它。謝謝。 – octopusgrabbus
@octopusgrabbus在那裏,我添加了缺失的行。 – Deleteman
在lein repl,你怎麼稱呼它?我剛剛進入(請求輸入)。無可否認,我將自己的區域設置爲一個項目。我會在我的答案中將項目和src標題作爲編輯發佈。 – octopusgrabbus