Datafunctions - multiple keys

• To: mathgroup at smc.vnet.net
• Subject: [mg89209] Datafunctions - multiple keys
• From: Mac <mwjdavidson at googlemail.com>
• Date: Thu, 29 May 2008 07:05:11 -0400 (EDT)

```With some help from a previous post I've become quite proficient at
simple data functions and use them quite frequently. Here a simplified
example:

Clear[f]
f["a"] := 1; f["b"] := 2;
f[] := Map[#[[1, 1, 1]] &, DownValues[f][[2 ;; All]]];

then I use f[] to get a list of keys

f[]
{"a", "b"}

and retrieve the function data using for instance f["a"] to retrieve
1. However I''m stumped as to how to extend this to more than one key.
There have been some posts in the past illustrating how to implement
multiple keys using a function of the form f[key1][key2], but I would
rather use something similar to the Wolfram data function
"ExampleData", where an empty call to example data, i.e. Example[] is
used to retrieve the high level categories and then
ExampleData["category"] is used to retrieve the examples within this
category. An example from my worksheet:

ExampleData[]

Out[91]= {"AerialImage", "Geometry3D", "LinearProgramming", "Matrix",
\
"Sound", "TestAnimation", "TestImage", "Text", "Texture"}

In[93]:= ExampleData["AerialImage"]

Out[93]= {{"AerialImage", "Earth"}, {"AerialImage",
"FosterCity"}, {"AerialImage", "Oakland"}, {"AerialImage",
"Oakland2"}, {"AerialImage", "Pentagon"}, {"AerialImage",
"Richmond"}, {"AerialImage", "Richmond2"}, {"AerialImage",
"SanDiego"}, {"AerialImage", "SanDiego2"}, {"AerialImage",
"SanDiego3"}, {"AerialImage", "SanDiego4"}, {"AerialImage",
"SanDiego5"}, {"AerialImage", "SanDiego6"}, {"AerialImage",
"SanDiego7"}, {"AerialImage", "SanDiego8"}, {"AerialImage",
"SanDiego9"}, {"AerialImage", "SanDiego10"}, {"AerialImage",
"SanDiego11"}, {"AerialImage", "SanDiego12"}, {"AerialImage",
"SanDiego13"}, {"AerialImage", "SanFrancisco"}, {"AerialImage",
"SanFrancisco2"}, {"AerialImage", "SanFrancisco3"}, {"AerialImage",
"SanFrancisco4"}, {"AerialImage", "SanFrancisco5"}, {"AerialImage",
"SanFrancisco6"}, {"AerialImage", "SanFrancisco7"}, {"AerialImage",
"SanFrancisco8"}, {"AerialImage", "SanFrancisco9"}, {"AerialImage",
"Shreveport"}, {"AerialImage", "Stockton"}, {"AerialImage",
"Stockton2"}, {"AerialImage", "Stockton3"}, {"AerialImage",
"Stockton4"}, {"AerialImage", "Stockton5"}, {"AerialImage",
"Stockton6"}, {"AerialImage", "WashingtonIR"}, {"AerialImage",
"WoodlandHills"}}

Any help would be much appreciated and used right away in my daily
programming.

Mac

```

• Prev by Date: Re: Re: Re: Integrate vs NIntegrate
• Next by Date: Mathematica 6: How to plot multiple lists with error bars?
• Previous by thread: Re: Deleting parts of notebooks programmatically
• Next by thread: Re: Datafunctions - multiple keys