(loop for i from (- end 1) downto start do (rotatef (aref sequence i) (aref sequence (random (+ i 1))))) should be
(loop for i from start below end do (rotatef (aref sequence i) (aref sequence (+ i (random (- end i)))))) otherwise the element selected won't be bound by [start, end),
similar bug in the sequence typed version Cheers,
Or
(loop for i from (- end 1) downto start do (rotatef (aref sequence i) (aref sequence (+ start (random (- (1+ i) start))))))
if you want a downward version.
On Tue, Nov 8, 2011 at 6:27 PM, Jianshi Huang jianshi.huang@gmail.com wrote:
(loop for i from (- end 1) downto start do (rotatef (aref sequence i) (aref sequence (random (+ i 1))))) should be
(loop for i from start below end do (rotatef (aref sequence i) (aref sequence (+ i (random (- end i)))))) otherwise the element selected won't be bound by [start, end),
similar bug in the sequence typed version Cheers, -- 黄 澗石 (Jianshi Huang) http://huangjs.net/
On 8 November 2011 11:27, Jianshi Huang jianshi.huang@gmail.com wrote:
(loop for i from (- end 1) downto start do (rotatef (aref sequence i) (aref sequence (random (+ i 1))))) should be
(loop for i from start below end do (rotatef (aref sequence i) (aref sequence (+ i (random (- end i)))))) otherwise the element selected won't be bound by [start, end),
similar bug in the sequence typed version
Fix pushed, thank you!
Cheers,
-- nikodemus
alexandria-devel@common-lisp.net