2006-10-24から1日間の記事一覧

演算 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 i…

事例:演算 merge

VDM++ での演算 merge に準拠した事例を紹介します。 m1 = VDM_Map({"A":1,"B":2}) m2 = VDM_Map({"A":1,"C":3}) ms = VDM_Set((m1,m2) ) print ">>> merge %s"%ms X = merge(ms) print X; assert X == VDM_Map({"A":1,"B":2,"C":3})(集合 ms の要素として…

演算 ++ を実現する

VDM++ での演算 ++ に準拠するように、メソッド VDM_Map.__add__ を実現します。class VDM_Map: def __add__(m1,m2): """ m1 ++ m2 ; map A to B * map A to B -> map A to B ; ; Override ; overrides and merges m1 with m2, i.e. it is like a ; merge ex…

事例:演算 ++

VDM++ での演算 ++ に準拠した事例(演算子 +)を紹介します。 m1 = VDM_Map({"A":1,"B":2}) m2 = VDM_Map({"A":1,"C":3}) print ">>> %s ++ %s"%(m1,m2) X = m1 + m2 print X; assert X == VDM_Map({"A":1,"B":2,"C":3})写像 m1 に m2 を上書きした写像を得…

演算 munion を実現する

VDM++ での演算 munion に準拠するように、メソッド VDM_Map.munion を実現します。class VDM_Map: def munion(m1,m2): """ m1 munion m2 ; (map A to B) * (map A to B) -> map A to B ; ; Merge ; yields a map combined by m1 and m2 such that ; the res…

事例:演算 munion

VDM++ での演算 munion に準拠した事例(VDM_Map.munion)を紹介します。 m1 = VDM_Map({"A":1,"B":2}) m2 = VDM_Map({"A":1,"C":3}) print ">>> %s munion %s"%(m1,m2) X = m1.munion(m2) print X; assert X == VDM_Map({"A":1,"B":2,"C":3})写像 m1 および…

写像の併合

VDM++ の map 型には、 複数の写像をもとに新たな写像を定義できます。VDM++ では、次のように表現します。 {"A" |-> 1, "B" |-> 2} munion {"A" |-> 1, "C" |-> 3} = {"A" |-> 1, "B" |-> 2, "C" |-> 3}2つの写像を併合した写像は {"A" |-> 1, "B" |-> 2, …

VDM++《17》Map に対する演算(2)

Shall_we_Agile = Java.use(better, Python) # Swing by VDM++《記事一覧》 改訂♪2008/09/07《承前》