将 Permutation 转换为 sage 6.2 中的列表并计算一些列表
converting Permutation to list in sage 6.2 and count some list
我尝试计算排列中的列表:
w = Permutations([])
w = w.list()
w.count([])
最后一行 w.count([])
在 sage 6.2 中的输出是 0
但在 sage 5.0 中是 1
我的问题是,为什么会这样????
我认为正确的是 1
排列的表示方式可能发生了变化。可以看到以下命令有不同的输出。
print type([])
print type(w[0])
为了计算排列 []
的出现次数,您可以先将其转换为排列。以下应该完成这项工作。
P = Permutations([])
elems = P.list()
elems.count(P([]))
我尝试计算排列中的列表:
w = Permutations([])
w = w.list()
w.count([])
最后一行 w.count([])
在 sage 6.2 中的输出是 0
但在 sage 5.0 中是 1
我的问题是,为什么会这样????
我认为正确的是 1
排列的表示方式可能发生了变化。可以看到以下命令有不同的输出。
print type([])
print type(w[0])
为了计算排列 []
的出现次数,您可以先将其转换为排列。以下应该完成这项工作。
P = Permutations([])
elems = P.list()
elems.count(P([]))