演算 merge を実現する

VDM++ での演算 merge に準拠するように(モジュール VDM_Map で)関数 merge を実現します。

def merge(set1):
"""
merge ms
; set of (map A to B) -> map A to B
;
; Distributed merge
; yields the map that is constructed by merging all
; the maps in ms. The maps in ms must be compat-
; ible.
"""
m = VDM_Map()
for e in ms.list:
m = m.munion(e)
return m

関数 merge では(集合 ms の要素として列挙された)すべての写像を併合した写像を生成して、これをリターン値とします。新たな写像 m を用意して、集合 ms に含まれるすべての写像 e を併合します。このとき、他で作成したメソッド munion を再利用しています。


《ひよ子のきもち♪2006/10/24》