[m-rev.] New library module: default_map.m
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Jul 11 22:30:17 AEST 2001
On 10-Jul-2001, Ralph Becket <rbeck at microsoft.com> wrote:
> I've needed something like this often enough that I think it should go
> in the standard library.
...
> Extend the library with a new map/2 variant that supports default values
> for keys that have not otherwise been bound in the map.
Hmm... how about just adding a variant of map__search/map__lookup
that takes a default?
E.g.
map__lookup_with_default(Map, Key, Default) =
(if map__search(Map, Key, Val) then Val else Default).
I've needed map__lookup_with_default often enough, but I don't think I've ever
needed to store the default in the map.
(Maybe you can think of a more concise name.)
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list