I am Charmie

メモとログ

Set in Python

集合(Set)を扱うPythonのモジュールを調べたり試したり.

  1. setモジュール/ set module
    1. len(s): 集合sの要素数を返す
    2. x in s: xがsのメンバーに含まれていればTrueを返す
    3. x not in s: xがsのメンバーに含まれていればTrueを返す
    4. s.isdisjoint(t): sとtが共通の要素を持たない時,すなわち互いに素(disjoint)な時にTrueを返す
    5. s.issubset(t): sがtの部分集合ならTrueを返す
    6. set <= other: setの全ての要素がotherに含まれればTrueを返す
    7. set < other: setがotherの真部分集合であればTrueを返す
    8. set >= other: otherの全ての要素がsetに含まれればTrueを返す
    9. set > other: setがotherの真上位集合であればTrueを返す
    10. set.union(other): setとotherの和集合を返す
    11. set.intersection(other): setとotherの積集合を返す
    12. set.difference(other): 差集合(setに含まれている要素のうち,otherに含まれていない要素を持つ集合)を返す
    13. set.add(elem): elemをsetの要素に追加
    14. set.remove(elem): setの要素elemを削除.elemがsetに含まれていなければKeyErrorを返す
    15. set.discard(elem): elemがsetの要素であれば削除
    16. set.pop(): setから任意に要素を選び削除.setがからであればKeyErrorを返す
    17. set.clear(): setの全要素を削除
  2. sympy.sets.sets.FiniteSet