2
我是CommonLisp noob,提问。下面我有这两个功能。Dolist评估错误
一个辅助函数:
(defun make-rests (positions rhythm)
"now make those positions negative numbers for rests"
(let ((resultant-rhythm rhythm))
(dolist (i positions resultant-rhythm)
(setf (nth i resultant-rhythm) (* (nth i resultant-rhythm) -1)))))
和一个主功能:
(defun test-return-rhythms (rhythms)
(let ((positions '((0 1) (0)))
(result nil))
(dolist (x positions (reverse result))
(push (make-rests x rhythms) result))))
当我运行(test-return-rhythms '(1/4 1/8))
,计算结果为:((1/4 -1/8) (1/4 -1/8))
不过,我预计:(test-return-rhythms '(1/4 1/8))
,以评估:((-1/4 -1/8) (-1/4 1/8))
。
我在做什么错?
啊,请注意,此功能将更好地命名为'拨动rests'。 – danlei
非常感谢! – user998509