0
我有以下Common Lisp的功能:有没有更好的方法来编写这个函数?
(defun get-positions (marker)
(let ((result nil))
(dotimes (i (length board))
(if (eq (nth i board) marker)
(push i result)))
(nreverse result)))
这里是board
是和这里的函数的输出:
CL-USER> board
(X X O NIL NIL NIL NIL NIL NIL)
CL-USER> (get-positions 'x)
(0 1)
好像我写的可能是一个有点冗长的功能。有没有更简洁的方式来编写它?