Re: associative arrays
- To: mathgroup at smc.vnet.net
- Subject: [mg58179] Re: [mg58137] associative arrays
- From: Ed Peschko <esp5 at mdssdev05.comp.pge.com>
- Date: Tue, 21 Jun 2005 06:02:56 -0400 (EDT)
- References: <d8rnfg$l4b$1@smc.vnet.net> <200506181007.GAA08771@smc.vnet.net> <200506190744.DAA05732@smc.vnet.net> <E89993C2-F308-430B-9064-8248DEF9D0C8@jeol.com>
- Sender: owner-wri-mathgroup at wolfram.com
On Mon, Jun 20, 2005 at 09:05:21AM -0400, Sseziwa Mukasa wrote:
>
> On Jun 19, 2005, at 3:44 AM, Ed Peschko wrote:
>
> >hey all,
> >
> >Is there a simple way to make an associative array in mathematica?
> >
> >I noticed that there's a sparse array, but I'd like to be able to
> >use a non-numeric value as key..
>
> Don't use arrays, use pattern matching eg:
>
> f[key1]=value1
> f[key2]=value2
> .
that does some things that I want, but I'm not sure if this is a 'true'
associative array, like perl's or python's dictionaries..
Can you:
a) list the keys in a given order, and iterate over them?
b) do true, multi-dimentional hashes, where both the key and
the value of the hash are either other hashes, or lists?
I know you can do ?f to list the values, but I'd like to be able to do
the 2 items above programatically.
Ed
- Follow-Ups:
- Re: Re: associative arrays
- From: Daniel Lichtblau <danl@wolfram.com>
- Re: Re: associative arrays
- References:
- Re: Transformation rule problem
- From: "Peltio" <peltio@trilight.zone>
- associative arrays
- From: Ed Peschko <esp5@mdssdev05.comp.pge.com>
- Re: Transformation rule problem