In Wolfram Mathematica,there is a function called Permutations
(http://reference.wolfram.com/mathematica/ref/Permutations.html).
It can gives all permutations containing exactly n elements.
For example: Permutations[{1,2,3,4}, {2}]
gives
{{1, 2}, {1, 3}, {1, 4}, {2, 1}, {2, 3}, {2, 4}, {3, 1}, {3, 2}, {3,
4}, {4, 1}, {4, 2}, {4, 3}}
I know Matlab have a similar function perms
, but it only receive one parameter and gives all possible permutations. Is there other function like Mathematica's Permutations[list,{n}]
?