MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: dictionaries?

  • To: mathgroup at
  • Subject: [mg20608] Re: dictionaries?
  • From: "John M. Jowett" <John.Jowett at>
  • Date: Thu, 4 Nov 1999 02:13:27 -0500
  • Organization: CERN
  • References: <7v3bov$>
  • Sender: owner-wri-mathgroup at

Joe Strout wrote:
> In Python, there's an extremely handy datatype called a "dictionary"
> which implements a many-to-1 mapping between keys (which can be any
> hashable type) and values (which can be anything).  E.g.:
> > d = {"one":1, "two":2}
> > d["one"]
> 1
> > d["three"]
> (key not found)
> I'm looking for something similar in Mathematica 

Depending on exactly what you want to do, Mathematica's rules may be fit
the bill, e.g., define a named set of rules

d = {one->1,two->2}

then you can have things like 

x[one] /. d


two + three /. d

2 + three

Rules are often a handy one to store a set of substitutions.

John Jowett
My home page:

  • Prev by Date: Re: M.U.C.
  • Next by Date: Plot Lines Too Thin V4.0
  • Previous by thread: Re: Re: hexagon tiled torus
  • Next by thread: Plot Lines Too Thin V4.0