[PATCH] Make MAP-PERMUTATIONS return the original sequence like MAP-(COMBINATIONS|DERANGEMENTS)

Steve Losh steve at stevelosh.com
Sat Feb 10 21:18:47 UTC 2018


MAP-COMBINATIONS and MAP-DERANGEMENTS both return the original sequence.  This
changes MAP-PERMUTATIONS to match their behavior.

MAP-PERMUTATIONS previously returned one of: the original sequence, NIL, or the
result of calling the function, depending on which code path happened to be
taken.

Patch attached.

-- 
Steve Losh
-------------- next part --------------
>From 98de3ff09a692bb94b814bcc42985f4ff6b1e1be Mon Sep 17 00:00:00 2001
From: Steve Losh <steve at stevelosh.com>
Date: Sat, 10 Feb 2018 16:12:07 -0500
Subject: [PATCH] Make MAP-PERMUTATIONS return the original sequence

MAP-COMBINATIONS and MAP-DERANGEMENTS both return the original sequence.
This changes MAP-PERMUTATIONS to match their behavior.

MAP-PERMUTATIONS previously returned one of: the original sequence, NIL,
or the result of calling the function, depending on which code path
happened to be taken.
---
 sequences.lisp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sequences.lisp b/sequences.lisp
index 118322a..fa73e90 100644
--- a/sequences.lisp
+++ b/sequences.lisp
@@ -469,7 +469,8 @@ length of the delimited subsequence."
                                 :start start
                                 :end end
                                 :length length
-                                :copy nil)))))))
+                                :copy nil))))))
+  sequence)
 
 (defun map-derangements (function sequence &key (start 0) end (copy t))
   "Calls FUNCTION with each derangement of the subsequence of SEQUENCE denoted
-- 
2.14.2



More information about the alexandria-devel mailing list