我發現它很難包圍我的頭。再說了,在Python,如果我想有我在基於用戶輸入一個循環修改名單,我有這樣的事情:類似Clojure的方式在一個循環中有一個數據結構
def do_something():
x = []
while(true):
input = raw_input('> ')
x.append(input)
print('You have inputted:')
for entry in x:
print(entry)
我真的不知道什麼是Clojure中,最喜歡的方式做類似的事情。到目前爲止,我有這樣的事情:
(defn -main
[arg]
(print "> ")
(flush)
(let [input (read-string (read-line))]
; Append a vector?
(println "You have inputted:")
; Print the contents of vector?
(recur <the vector?>)))
基本上,我追加載體,並給予載體作爲參數下一個遞歸循環。這是做這件事的正確方法嗎?我甚至不知道我會如何做到這一點,但我就是這麼做的。我將在哪裏「存儲」矢量?任何幫助?