Union 
例題
すべて開く すべて閉じる例 (3)
スコープ (1)
一般化と拡張 (1)
オプション (4)
SameTest (4)
Union[{2, -2, 1, 3, 1}, SameTest -> (Abs[#1] == Abs[#2]&)]Floorに基づく同等のクラスを使う:
Union[{1.1, 3.4, .5, 7.6, 7.1, 1.9}, SameTest -> (Floor[#1] == Floor[#2]&)]リスト要素のTotalを使う:
Union[{{1, 2}, {3}, {4, 5, 6}, {9, 6}}, SameTest -> (Total[#1] == Total[#2]&)]Union[{{1, 2}, {2, 1}, {3, 2, 1}, {3}, {4, 5}, {5, 4, 3, 2, 1}}, SameTest -> (First[#1] == Last[#2]&)]アプリケーション (4)
Union[Divisors[10], Divisors[12], Divisors[20]]10!のバイナリ分解で生じる数字3個のすべての組合せを求める:
Union[Partition[IntegerDigits[10!, 2], 3, 1]]Union[NestList[Mod[5#, 11]&, 1, 100]]Union[Flatten[Map[Options[#][[All, 1]]&, {FindFit, FindMinimum, FindRoot}]]]特性と関係 (3)
ints = RandomInteger[9, 10]splits = Split[Sort[ints]]Union[ints] === splits[[All, 1]]Tallyは同一要素の数を求め,もとの順番で返す:
ints = RandomInteger[9, 10]tally = Tally[ints]和集合はTallyで返された要素をソートしたリストである:
Union[ints] === Sort[tally[[All, 1]]]DeleteDuplicatesは,ソートなしのUnionに似ている:
list = {9, 0, 0, 3, 2, 3, 6, 2, 9, 8, 4, 9, 0, 2, 6, 5, 7, 4, 9, 8};Union[list]DeleteDuplicates[list]Sort[%]list = RandomInteger[10 ^ 5, 10 ^ 7];{First[Timing[DeleteDuplicates[list]]], First[Timing[Union[list]]]}考えられる問題 (1)
大きい集合の場合,UnionはSameTestと共に使うとすべてのペアの比較をするので遅くなることがある:
ints = RandomInteger[1000, 1000];Timing[Length[u = Union[ints, SameTest -> (Floor[#1 / 2] == Floor[#2 / 2]&)]]]等価クラスの代表が見付かる場合は,それらにUnionを使った方が速いことがある:
Timing[Length[fu = 2 * Union[Floor[ints / 2]]]]Union[u - fu]関連項目
Join Intersection Complement SymmetricDifference Tally DeleteDuplicates BinLists Split Or BitOr
文字: \[Union]
Function Repository: MultisetUnion MultisetSum
テクニカルノート
-
▪
- リストの結合 ▪
- リストの集合論的扱い
関連するガイド
-
▪
- リストの並べ替えと再構築 ▪
- 集合の操作 ▪
- 離散データと整数データ ▪
- リストへの数学的およびカウント操作 ▪
- データ集合に対するデータベース様の操作 ▪
- 有限数学 ▪
- データの配列の操作 ▪
- 離散数学 ▪
- 表形式の変換 ▪
- 構造化されたデータ集合の計算 ▪
- 数値データ
履歴
1988 で導入 (1.0) | 1996 で更新 (3.0)
テキスト
Wolfram Research (1988), Union, Wolfram言語関数, https://reference.wolfram.com/language/ref/Union.html (1996年に更新).
CMS
Wolfram Language. 1988. "Union." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 1996. https://reference.wolfram.com/language/ref/Union.html.
APA
Wolfram Language. (1988). Union. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Union.html
BibTeX
@misc{reference.wolfram_2026_union, author="Wolfram Research", title="{Union}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/Union.html}", note=[Accessed: 21-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_union, organization={Wolfram Research}, title={Union}, year={1996}, url={https://reference.wolfram.com/language/ref/Union.html}, note=[Accessed: 21-June-2026]}