Skip to content

Commit

Permalink
Add new function mapReplaceAdd
Browse files Browse the repository at this point in the history
This is used in McLachlan to manipulate calculations
  • Loading branch information
eschnett authored and ianhinder committed Sep 29, 2011
1 parent 89a1637 commit bee7aeb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Tools/MathematicaMisc/MapLookup.m
Expand Up @@ -4,6 +4,7 @@
lookup::usage = "";
mapContains::usage = "";
mapReplace::usage = "";
mapReplaceAdd::usage = "";
mapValueMap::usage = "";
lookupDefault::usage = "";
mapValueMapMultiple::usage = "";
Expand Down Expand Up @@ -59,6 +60,13 @@
VerifyMap[map];
Map[If[First[#] === key, key -> value, #] &, map]];

mapReplaceAdd[map_, key_, value_] :=
Module[{},
VerifyMap[map];
If[mapContains[map, key],
mapReplace[map, key, value],
mapAdd[map, key, value]]];

mapAdd[map_, key_, value_] :=
Module[{},
VerifyMap[map];
Expand Down

0 comments on commit bee7aeb

Please sign in to comment.