如何修改该"make-matrix"?功能? [英] How to modify this "make-matrix" function?
本文介绍了如何修改该"make-matrix"?功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗯,有缺陷的功能如下:
Well, the flawed function is as follows:
(defun make-matrix (n)
(make-array (n n) :initial-element 0))
我想使用像(make-matrix 8)
这样的函数来替换更长的(make-array '(8 8) :initial-element 0)
,但是CLISP说(n n)
中存在错误,因为n
不是已定义的函数.如何编写此make-matrix
函数?
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?
推荐答案
您尝试使用(n n)
,但这是Lisp语法,用于使用参数n
调用名为n
的函数.您应该像这样调用make-array
:
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)
这篇关于如何修改该"make-matrix"?功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文