How to modify this “make-matrix” function?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 08:12:53

问题


Well, the flawed function is as follows:

(defun make-matrix (n)
  (make-array (n n) :initial-element 0))

I want to use functions like (make-matrix 8) to replace the longer (make-array '(8 8) :initial-element 0), but CLISP says there is a fault in (n n), because n is not a defined function. How do I write this make-matrix function?


回答1:


You try to use (n n), but that is Lisp syntax for calling a function named n with an argument n. You should invoke make-array like this:

(make-array (list n n) :initial-element 0)


来源:https://stackoverflow.com/questions/19678906/how-to-modify-this-make-matrix-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!