SymPy | Python中的 Subset.subset_indices()
Subset.subset_indices() :subset_indices()是一个 sympy Python库函数,它返回列表中超集中子集的索引
Syntax :
sympy.combinatorics.subset.Subset.subset_indices()
Return :
the indices of subset in superset in a list
if all elements of subset are not in superset. – list is empty
代码 #1:subset_indices() 示例
# Python code explaining
# SymPy.Subset.subset_indices()
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
# Using from
# sympy.combinatorics.subset.Subsets.subset_indices()
# superset
super_set = [4, 3, 2, 7]
# Creating Subset
a = Subset.subset_indices((['geek', 'for', 'c', 'd']), super_set)
# subset_indices value
print ("Subset a subset_indices : ", a)
输出 :
Subset a subset_indices : []
代码 #2:subset_indices() 示例
# Python code explaining
# SymPy.Subset.subset_indices()
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
# Using from
# sympy.combinatorics.subset.Subsets.subset_indices()
# superset
super_set = [4, 3, 2, 7]
# Creating Subset
a = Subset.subset_indices(([2, 3, 4]), super_set)
# subset_indices value
print ("Subset a subset_indices : ", a)
输出 :
Subset a subset_indices : [2, 1, 0]