aboutsummaryrefslogtreecommitdiff
path: root/Tools/MathematicaMisc
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2011-09-28 09:31:48 +0200
committerIan Hinder <ian.hinder@aei.mpg.de>2011-09-29 20:57:09 +0200
commitbee7aebdba5f888c0b3913767f94047bd4ea6b88 (patch)
tree935a67f943f7d153ccdbc6c77a3366d5453d3144 /Tools/MathematicaMisc
parent89a16379672be072fd18c9a805c03e766691c3d3 (diff)
Add new function mapReplaceAdd
This is used in McLachlan to manipulate calculations
Diffstat (limited to 'Tools/MathematicaMisc')
-rw-r--r--Tools/MathematicaMisc/MapLookup.m8
1 files changed, 8 insertions, 0 deletions
diff --git a/Tools/MathematicaMisc/MapLookup.m b/Tools/MathematicaMisc/MapLookup.m
index 1711cdf..ee0c85b 100644
--- a/Tools/MathematicaMisc/MapLookup.m
+++ b/Tools/MathematicaMisc/MapLookup.m
@@ -4,6 +4,7 @@ BeginPackage["MapLookup`", {"Errors`"}];
lookup::usage = "";
mapContains::usage = "";
mapReplace::usage = "";
+mapReplaceAdd::usage = "";
mapValueMap::usage = "";
lookupDefault::usage = "";
mapValueMapMultiple::usage = "";
@@ -59,6 +60,13 @@ mapReplace[map_, key_, value_] :=
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];