Complement[eall,e1,e2,…]
eall内のいずれの eiでもない要素を与える.
Complement
Complement[eall,e1,e2,…]
eall内のいずれの eiでもない要素を与える.
詳細とオプション
- Complementが返すリストは標準的な順に並べ替えられる.
- Complement[eall,e1,…,SameTest->test]は,eallの要素と eiからなるそれぞれのペアに test を適用して同じであるかどうかを決定する.
例題
すべて開く すべて閉じる例 (1)
一般化と拡張 (1)
ComplementはListだけでなく,任意の頭部に使うことができる:
Complement[f[a, b, c, d], f[c, a], f[b, b, a]]オプション (3)
SameTest (3)
Complement[{2, -2, 1, 3}, {2, 1, -2, -1}, SameTest -> (Abs[#1] == Abs[#2]&)]Floorに基づいた等価クラスを使う:
Complement[{1.1, 3.4, .5, 7.6, 7.1, 1.9}, {1.2, 3.3, 1.3}, SameTest -> (Floor[#1] == Floor[#2]&)]リスト要素のTotalを使う:
Complement[{{1, 2}, {3}, {4, 5, 6}, {9, 5}}, {{2, 1}, {8, 4, 3}}, SameTest -> (Total[#1] == Total[#2]&)]アプリケーション (4)
Complement[Divisors[20], Divisors[12]]次の3つの数字の組合せのどれが12345をバイナリ分解した際に起らないかを求める:
Complement[Tuples[{0, 1}, 3], Partition[IntegerDigits[12345, 2], 3, 1]]PlotのどのオプションがGraphicsのオプションではないかを求める:
Complement[First /@ Options[Plot], First /@ Options[Graphics]]長さが5の文字列のうちどれが任意の初歩的セルオートマトンを2ステップ進化させた後では決して起らないかを求める:
Complement[Tuples[{0, 1}, 5], Table[Last[CellularAutomaton[i, {{1}, 0}, {2, All}]], {i, 0, 255}]]特性と関係 (1)
Complement[list1,list2]の結果はソートされており,繰り返される要素は含んでいない:
Complement[{b, e, d, a, b, c, d}, {b, c}]以下も同じ結果を返すが,list1のもとの順序と多重度を保持している:
DeleteCases[{b, e, d, a, b, c, d}, Alternatives@@{b, c}]DeleteDuplicatesを使って順序を保持しつつ多重度を削除する:
DeleteDuplicates[%]テクニカルノート
関連するガイド
-
▪
- リストの並べ替えと再構築 ▪
- 集合の操作 ▪
- リストへの数学的およびカウント操作 ▪
- 離散数学 ▪
- 表形式の変換 ▪
- 離散データと整数データ
履歴
1988 で導入 (1.0) | 1996 で更新 (3.0)
テキスト
Wolfram Research (1988), Complement, Wolfram言語関数, https://reference.wolfram.com/language/ref/Complement.html (1996年に更新).
CMS
Wolfram Language. 1988. "Complement." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 1996. https://reference.wolfram.com/language/ref/Complement.html.
APA
Wolfram Language. (1988). Complement. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Complement.html
BibTeX
@misc{reference.wolfram_2026_complement, author="Wolfram Research", title="{Complement}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/Complement.html}", note=[Accessed: 11-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_complement, organization={Wolfram Research}, title={Complement}, year={1996}, url={https://reference.wolfram.com/language/ref/Complement.html}, note=[Accessed: 11-September-2026]}