0
我是一個功能性編程的初學者,我試圖打印一個迷宮。
這裏是我的功能復發函數的參數號錯誤
(defn pprint-maze
[arr row col]
(loop [coll arr idx 0]
(match [idx]
[(_ :guard #(= (mod idx col) 0))] (println "") ; write a \n
:else (print "-")) ; write a wall
(when (next coll)
(recur (next coll) (inc idx)))))
我的功能需要收集和迷宮的大小和現在,只打印一個破折號和\ n在該行的末尾。 我有它的問題是: Exception in thread "main" clojure.lang.ArityException: Wrong number of args (1) passed to: core/pprint-maze/fn--4873/fn--4874
我覺得功能指出的是我的循環功能,以及相匹配的問題是有關(因爲當我評論的匹配塊,一切工作)。我認爲這個匹配嘗試用nil作爲參數來調用循環函數(println函數的返回值)。
如何解決?
...因爲'#(...)'表格不包含'%'或'%1'標記。 – Thumbnail