MathTop

nextperm 函数

返回 1..n 的排列在字典序中的下一个排列;到达边界时返回 FAIL。

语法

  • combinat:-nextperm(permutation)
  • combinat[nextperm](permutation)
  • nextperm(permutation)

参数与选项

permutation包含 1 到 n 且每个整数恰好出现一次的排列列表。

示例

  1. 下一个排列combinat:-nextperm([1, 3, 2])返回 [2, 1, 3]。