Also, The assoc function (enter ? assoc) might be useful.
--Barton
maxima-bounces at math.utexas.edu wrote on 02/07/2012 12:29:32 PM:
> From: Edd Barrett <vext01 at gmail.com>
> To: Jaime Villate <villate at fe.up.pt>
> Cc: maxima at math.utexas.edu
> Date: 02/07/2012 12:25 PM
> Subject: Re: [Maxima] "guarded" fetch from hashed array
> Sent by: maxima-bounces at math.utexas.edu
>
> On Tue, Feb 07, 2012 at 05:52:49PM +0000, Jaime Villate wrote:
> > On 02/07/2012 04:38 PM, Edd Barrett wrote:
> > >I wish to use a hash table to store a mapping from a variable name to
a
> > >list of coefficients. This is accomplished easily enough in maxima,
> > >however, is there a way of throwing an error if the key accessed is
not
> > >a key in the hash table?
> > Have you tried with atom?
> >
> > (%i2) hash[a]: "aaa"$
> > (%i3) atom(hash[a]);
> > (%o3) true
> > (%i4) atom(hash[b]);
> > (%o4) false
>
> Great.
>
> Actually, my hash contains lists, so I can use listp() similarly.
>
> I bet there is a better way still...
>
> --
> Best Regards
> Edd Barrett
>
> http://www.theunixzoo.co.uk
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima