[m-dev.] map.merge

Ian MacLarty maclarty at csse.unimelb.edu.au
Mon Jul 10 11:38:48 AEST 2006


Hello,

The documentation of map.merge says:

    % For map.merge(MapA, MapB, Map), MapA and MapB must not both
    % contain the same key.
    %
:- func map.merge(map(K, V), map(K, V)) = map(K, V).
:- pred map.merge(map(K, V)::in, map(K, V)::in, map(K, V)::out) is det.

However it doesn't say what happens if they do have the same key.  I
investigated and it appears that map.merge won't throw an exception if
the same key appears in both maps, but will set the corresponding value
to the greatest value from the two maps.  Wouldn't it be more
appropriate to throw an exception?

Ian.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list