Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8688

Re: How best to implement a hash table in Mathematica

From Joseph Gwinn <joegwinn@comcast.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: How best to implement a hash table in Mathematica
Date 2012-02-22 10:35 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <ji2ge6$kcc$1@smc.vnet.net> (permalink)
References <jho21j$5sb$1@smc.vnet.net> <jhqmrr$fbq$1@smc.vnet.net> <jhstsv$nk0$1@smc.vnet.net> <jhvuoi$891$1@smc.vnet.net>

Show all headers | View raw


In article <jhvuoi$891$1@smc.vnet.net>,
 Szabolcs Horvát <szhorvat@gmail.com> wrote:

> 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.

I'll have to try this and related approaches, but it's not the entire 
hashtable that's empty, it's this or that element of said hashtable.


> 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.

Well, I use initial (and embedded) caps all the time, for readable 
symbols, and Mathematica does sometimes balk, so I make the symbol a word 
longer.  

As for HashTable, Mathematica complained, so I changed it to BigHashTable, and 
peace was restored.

Joe Gwinn

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How best to implement a hash table in Mathematica Joseph Gwinn <joegwinn@comcast.net> - 2012-02-18 11:28 +0000
  Re: How best to implement a hash table in Mathematica Szabolcs Horvát <szhorvat@gmail.com> - 2012-02-19 11:29 +0000
    Re: How best to implement a hash table in Mathematica Joseph Gwinn <joegwinn@comcast.net> - 2012-02-20 07:50 +0000
  Re: How best to implement a hash table in Mathematica David Bailey <dave@removedbailey.co.uk> - 2012-02-19 11:36 +0000
    Re: How best to implement a hash table in Mathematica Joseph Gwinn <joegwinn@comcast.net> - 2012-02-20 07:48 +0000
      Re: How best to implement a hash table in Mathematica A Retey <awnl@gmx-topmail.de> - 2012-02-21 11:20 +0000
        Re: How best to implement a hash table in Mathematica Joseph Gwinn <joegwinn@comcast.net> - 2012-02-22 10:36 +0000
      Re: How best to implement a hash table in Mathematica Szabolcs Horvát <szhorvat@gmail.com> - 2012-02-21 11:21 +0000
        Re: How best to implement a hash table in Mathematica Joseph Gwinn <joegwinn@comcast.net> - 2012-02-22 10:35 +0000
  Re: How best to implement a hash table in Mathematica Richard Fateman <fateman@cs.berkeley.edu> - 2012-02-19 11:36 +0000
    Re: How best to implement a hash table in Mathematica Joseph Gwinn <joegwinn@comcast.net> - 2012-02-20 07:49 +0000
      Re: How best to implement a hash table in Mathematica Richard Fateman <fateman@cs.berkeley.edu> - 2012-02-21 11:11 +0000
        Re: How best to implement a hash table in Mathematica Joseph Gwinn <joegwinn@comcast.net> - 2012-02-22 10:36 +0000
  Re: How best to implement a hash table in Mathematica Leonid Shifrin <lshifr@gmail.com> - 2012-02-22 10:34 +0000
    Re: How best to implement a hash table in Mathematica "Nasser M. Abbasi" <nma@12000.org> - 2012-02-23 10:51 +0000
  Re: How best to implement a hash table in Mathematica Leonid Shifrin <lshifr@gmail.com> - 2012-02-24 06:00 +0000

csiph-web