【发布时间】:2013-10-22 11:33:30
【问题描述】:
在 Wolfram Mathematica 中,有一个函数叫做Permutations(http://reference.wolfram.com/mathematica/ref/Permutations.html)。
它可以给出恰好包含 n 个元素的所有排列。
例如:Permutations[{1,2,3,4}, {2}] 给予
{{1, 2}, {1, 3}, {1, 4}, {2, 1}, {2, 3}, {2, 4}, {3, 1}, {3, 2}, {3,
4}, {4, 1}, {4, 2}, {4, 3}}
我知道 Matlab 有一个类似的函数perms,但它只接收一个参数并给出所有可能的排列。有没有像Mathematica的Permutations[list,{n}]这样的功能?
【问题讨论】:
标签: algorithm matlab wolfram-mathematica permutation