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)
私が書いた関数は少し冗長かもしれないように思え。それを書くより簡潔な方法がありますか?