Python.use(better, VDM++) #union -- union
‖記事一覧‖
union -- union
《著》小粒ちゃん+∞《監修》小泉ひよ子とタマゴ倶楽部
第0版♪2000/04/03 ● 第1版♪2003/05/23 ● 第2版♪2006/10/01 ● 第3版♪2009/10/07
事例:モジュールを起動する
■ 全項目を確認する
全ステップの「項目」を確認するには、関数 do を利用します。
$ python VDM_set.py >>> do() 0: step00 -- def VDM_set(): ... >>>
>>> help(VDM_set.union) ... union(s1, s2) s1 union s2 ; set of A * set of A -> set of A ; ; Union ; yields the union of the sets s1 and s2, i.e. the ; set containing all the elements of both s1 and ; s2.
■ 各項目を実行する
各ステップの「動作」を確認するには、関数 do に実引数を指定します。
>>> do(@) >>> # -------------------------------------------------- union >>> s1 = VDM_set() >>> s2 = VDM_set("AB") >>> s1.union(s2) {'A', 'B'} >>> s1 + s2 {'A', 'B'} >>> s1 = VDM_set("A") >>> s2 = VDM_set("B") >>> s1.union(s2) {'A', 'B'} >>> s1 + s2 {'A', 'B'} >>> s1 = VDM_set("AB") >>> s2 = VDM_set("BC") >>> s1.union(s2) {'A', 'B', 'C'} >>> s1 + s2 {'A', 'B', 'C'}
2つの集合 A, B の「どちらかに」含まれる要素を列挙した、和集合 A∪B が得られます。
事例:コードの解説
VDM/set
Operator | Name | Type |
---|---|---|
e in set s1 | Membership | A ∗ set of A → bool |
e not in set s1 | Not membership | A ∗ set of A → bool |
s1 union s2 | Union | set of A ∗ set of A → set of A |
s1 inter s2 | Intersection | set of A ∗ set of A → set of A |
s1 \ s2 | Difference | set of A ∗ set of A → set of A |
s1 subset s2 | Subset | set of A ∗ set of A → bool |
s1 psubset s2 | Proper subset | set of A ∗ set of A → bool |
s1 = s2 | Equality | set of A ∗ set of A → bool |
s1 <> s2 | Inequality | set of A ∗ set of A → bool |
card s1 | Cardinality | set of A → nat |
dunion ss | Distributed union | set of set of A → set of A |
dinter ss | Distributed intersection | set of set of A → set of A |
power s1 | Finite power set | set of A → set of set of A |
- Note that the types A, set of A and set of set of A are only meant to illustrate
》こちらに移動中です《
↑TOP