% $Id$ declare % This version is wrong!!! It doesn't follow the grammar! fun {MaxAmounts SalesData} case SalesData of store(address: Addr amounts: Amts) then store(address: Addr amounts: [{MaxAmounts Amts}]) %% not following the grammar! [] group(name:Name members: Mems) then group(name:Name members: {MaxAmounts Mems}) %% not following the grammar! [] Amt|RestAmts then {Max Amt {MaxAmounts RestAmts}} [] nil then 0 %% The following never execute, because the patterns above are the same [] Mem|RestMems then {MaxAmounts Mem}|{MaxAmounts RestMems} [] nil then nil end end fun {ListMax Lst} case Lst of H|T then {Max H {ListMax T}} else 0 end end fun {MaxAmountsList LOSD} case LOSD of D|Rest then {MaxAmounts D} | {MaxAmountsList Rest} else nil end end