Commit 5b5f7c84 authored by Nikodemus Siivola's avatar Nikodemus Siivola
Browse files

fix MAP-PERMUTATIONS

 Editing damage: extra IF surrounding the permutation guts. Also add a
 trivial test-case.
parent 56bd6c16
......@@ -396,12 +396,11 @@ length of the delimited subsequence."
(funcall function (if copy
(copy-seq seq)
seq))
(if (evenp n-1)
(loop for i from 0 upto n-1
do (permute seq n-1)
(if (evenp n-1)
(rotatef (elt seq 0) (elt seq n-1))
(rotatef (elt seq i) (elt seq n-1))))))))
(loop for i from 0 upto n-1
do (permute seq n-1)
(if (evenp n-1)
(rotatef (elt seq 0) (elt seq n-1))
(rotatef (elt seq i) (elt seq n-1)))))))
(permute-sequence (seq)
(permute seq length)))
(if (= length size)
......
......@@ -983,6 +983,22 @@
(1 3)
#(2 3)))
(deftest map-permutations.1
(let ((seq (list 1 2 3))
(seen nil)
(ok t))
(map-permutations (lambda (s)
(unless (set-equal s seq)
(setf ok nil))
(when (member s seen :test 'equal)
(setf ok nil))
(push s seen))
seq
:copy t)
(values ok (length seen)))
t
6)
(deftest proper-sequence.type.1
(mapcar (lambda (x)
(typep x 'proper-sequence))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment