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)
好像我寫的可能是一個有點冗長的功能。有沒有更簡潔的方式來編寫它?