我怎样才能避免最后打印的 nil ? [英] How can I avoid the nil printed in the end?
本文介绍了我怎样才能避免最后打印的 nil ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经编写了这个打印出板子状态的函数,但最后,由于没有返回这个函数打印一个零!
I have coded this function that prints-out the state of the board, but in the end, due to the fact that there isnt no return the function prints an nil!
功能:
(defun show-board (board)
(dotimes (number 8)
(dotimes (number2 8)
(let ((pos (aref board number number2)))
(cond
((equal pos 0) (format t "~a " "B"))
((equal pos 1) (format t "~a " "P"))
(t (format t "~a " "L")))))
(format t "~%")))
板是一个 8x8 阵列!
A board is an 8x8 array!
命令行上的函数调用输出:
function call output on command lines:
B P B P B P B P
P B P B P B P B
B P B P B P B P
P B P B P B P B
B P B P B P B P
P B P B P B P B
B P B P B P B P
P B P B P B P B
NIL
我怎样才能摆脱 NIL??
How can i get rid of the NIL??
推荐答案
添加 (values)
作为 dotimes
的返回表单即可:
adding (values)
as return form for dotimes
will do it:
(dotimes (number 8 (values))
.....)
毕竟,show-board
确实不返回任何值,对吧?
after all, show-board
indeed doesn't return any values, right?
这篇关于我怎样才能避免最后打印的 nil ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文