MathGroup Archive 2012

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

Search the Archive

Re: How best to implement a hash table in Mathematica


On 2/20/2012 9:48 AM, Joseph Gwinn wrote:
>
> The reason to initialize the hashtable in advance is so a later probe to
> an empty table element yields {}, versus repeating the question back.
>
>

I probably don't understand your question completely, but why can't you 
just make definition like

hashtable[_] = {}

?  This will ensure that {} is returned for "undefined" keys.

Also, please avoid using symbols that start with a capital letter. 
HashTable is a built-in symbol and if you define it (as you did in the 
example code you sent), it is likely to break stuff.

-- 
Szabolcs Horvát
Visit Mathematica.SE:  http://mathematica.stackexchange.com/



  • Prev by Date: Re: Why HoldForm[] shows this expression in red in notebook?
  • Next by Date: Re: NDSolve solutions
  • Previous by thread: Re: How best to implement a hash table in Mathematica
  • Next by thread: Re: How best to implement a hash table in Mathematica