J's dictionary data type is probably the locale. http://www.jsoftware.com/pipermail/programming/2014-February/035615.html has a list of urls documenting locales.
That said, note that names within locales have syntactic limits. So you'd have to map your identifier into something suitable as a name. This process is analogous to hashing or to numeric base conversion. For example: thru=: [ + 1 i.@+ -~ 10 thru 20 10 11 12 13 14 15 16 17 18 19 20 alph=: a.&i. alph 'az' 97 122 NB. say this with a guido sarducci accent: thrua=: thru&.alph 'a' thrua 'z' abcdefghijklmnopqrstuvwxyz namechars=: '_',('a' thrua 'z'),('A' thrua 'Z'),'0' thrua '9' num2name=: [ , namechars {~ (#namechars) #.inv ] 'prefix' num2name 8675309 prefixHQVt The prefix prevents accidental collisions with other names within the locale, if you need that. So if we want a dictionary with numeric keys (which could instead have been a sparse array), we might use: dictname=: ('z' num2name ]) , '_', [ ,'_'"_ setdict=:1 :0 : (m dictname x)=: y ) getdict=: ".@dictname 123 'example' setdict |:i.3 2 0 2 4 1 3 5 'example' getdict 123 0 2 4 1 3 5 So anything that you can convert to a nonnegative integer can be used as dictionary key with a system like this. Obviously, though, other systems are possible. (For example, you could use a sparse array instead of a locale, that will give you different performance characteristics.) And I see Pascal Jasmin has just now posted a similar proposal, so I'll stop here - I really have some other tasks I need to get done. Thanks, -- Raul On Mon, Mar 3, 2014 at 10:06 AM, Yike Lu <yikelu.h...@gmail.com> wrote: > A tangential but related question: does J have a dictionary data type? > Where can I read about it? > > Thanks. > > > On Mon, Mar 3, 2014 at 8:55 AM, Tracy Harms <kalei...@gmail.com> wrote: > >> My naïve intuition is that a tree of symbols would be the most direct route >> to increased performance. Would that fit with what you suggested here, >> Raul? >> On Mar 3, 2014 1:52 AM, "Raul Miller" <rauldmil...@gmail.com> wrote: >> >> > We should be able to concatenate boxed arrays with somewhat better >> > performance. Conceptually speaking, the added box can be treated as an >> > opaque string (other than reference counting bumps) for the purpose of >> the >> > concatenation operation. Conceptually, also, already have some way of >> > allocating memory in "power of two sized blocks". But memory management >> is >> > a subtle thing, so maybe there is something I am missing? >> > >> > Thanks, >> > >> > -- >> > Raul >> > >> > >> > On Mon, Mar 3, 2014 at 12:26 AM, bill lam <bbill....@gmail.com> wrote: >> > >> > > I would be quite happy if J can do that in a few minutes. The >> > > bottle neck is not string related but J converts Json data into a >> > > box array. Because concatenation of box arrays cannot be done >> > > in place, it re-constructs a new box array for each node and this >> > > is quadratic. >> > > >> > > Even if you can use python to parse json, it will still take a >> > > quadratic operation to convert that parsed data structure >> > > back to a J box array. Untested. >> > > >> > > Пн, 03 мар 2014, June Kim (김창준) писал(а): >> > > > Hello, >> > > > >> > > > I recently tried to work on a JSON file (a bookmark file from Chrome >> > > > browser), which is about 28MB. My initial attempt was using the json >> > > parser >> > > > from the J packages. Oh, it was slow. It took more than one minute on >> > my >> > > > machine. >> > > > >> > > > Disappointed, but I was kind of expecting the slow performance >> because >> > > > string and tree are not what J's strength is. >> > > > >> > > > Now I turned to Python and tried parsing the file using the standard >> > > > package. Oh, I took about a second. >> > > > >> > > > So I can proceed with Python but I want to know if there are any >> other >> > > > options working with J with better performance. >> > > > >> > > > June >> > > > >> ---------------------------------------------------------------------- >> > > > For information about J forums see >> http://www.jsoftware.com/forums.htm >> > > >> > > -- >> > > regards, >> > > ==================================================== >> > > GPG key 1024D/4434BAB3 2008-08-24 >> > > gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 >> > > gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3 >> > > ---------------------------------------------------------------------- >> > > For information about J forums see http://www.jsoftware.com/forums.htm >> > > >> > ---------------------------------------------------------------------- >> > For information about J forums see http://www.jsoftware.com/forums.htm >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm