递归函数的参数编号错误

我是函数编程的初学者,我尝试漂亮地打印迷宫。
这是我的功能

(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

我认为指出的功能是我的循环功能,并且问题与匹配有关(因为当我注释匹配块时,一切正常)。我认为match尝试使用nil作为参数调用循环函数(println函数的返回)。

怎么解决呢?

合金

传递给该函数的函数:guard应仅使用一个参数,该值应受保护。您的函数采用零参数。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章