📜  SymPy | Python中的 Subset.prev_lexicographic()

📅  最后修改于: 2022-05-13 01:55:20.942000             🧑  作者: Mango

SymPy | Python中的 Subset.prev_lexicographic()

Subset.prev_lexicographic() :prev_lexicographic()是一个 sympy Python库函数,它返回前一个按字典顺序排列的子集。

代码 #1:prev_lexicographic() 示例

# Python code explaining
# SymPy.Subset.prev_lexicographic()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.prev_lexicographic()
  
# Creating Subset
a = Subset(['c', 'd'], ['geek', 'for', 'c', 'd'])
  
# prev_lexicographic value
print ("Subset a prev_lexicographic : ", a.prev_lexicographic().subset)

输出 :

代码 #2:prev_lexicographic() 示例

# Python code explaining
# SymPy.Subset.prev_lexicographic()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.prev_lexicographic()
  
# Creating Subset
a = Subset([2, 3, 4], [1, 2, 3, 4, 5])
  
# prev_lexicographic value
print ("Subset a prev_lexicographic : ", a.prev_lexicographic().subset)

输出 :