Skip to content

Commit

Permalink
MapLookup.m: Use DefFn for lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhinder committed Jan 25, 2012
1 parent e0fb62f commit 5ca7066
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Tools/MathematicaMisc/MapLookup.m
Expand Up @@ -28,10 +28,11 @@
ThrowError["Expecting a map (list of rules) but found", m]];
Map[VerifyRule, m]];

lookup[map_, key_, default_] :=
lookupDefault[map, key, default];
DefFn[
lookup[map_List, key_Symbol, default_] :=
lookupDefault[map, key, default]];

lookup[map_, key_] :=
DefFn[lookup[map_List, key_Symbol] :=
Module[{values},
VerifyMap[map];

Expand All @@ -41,7 +42,7 @@
If[Length[values] > 1,
ThrowError["lookup failure: key ", key, " found multiple times in map", map]];

First[values][[2]]];
First[values][[2]]]];

mapContains[map_, key_] :=
Module[{},
Expand Down

0 comments on commit 5ca7066

Please sign in to comment.