Handbook
Glossary
unique-permutations ( ... seq i n quot: ( ... elt -- ... ) -- ... )
Vocabulary
math
.
combinatorics
.
private
Inputs
seq
an
object
i
an
object
n
an
object
quot
a
quotation
with stack effect
( ... elt -- ... )
Outputs
None
Definition
USING:
kernel
math
ranges
sequences
sequences.private
;
IN:
math.combinatorics.private
::
unique-permutations
( ... seq i n quot: ( ... elt -- ... ) -- ... )
i n
>=
[
seq
clone
quot
call
]
[
i n
[a..b)
[|
j |
i j seq
should-swap?
[
i j seq
exchange-unsafe
seq i 1
+
n quot
unique-permutations
i j seq
exchange-unsafe
]
when
]
each
]
if
;
inline
recursive