Re: [Jprogramming] Dictionary with Strings as Keys

2017-04-16 Thread Herbert Weissenbaeck // Privat
Thank you, Ian. Most helpful. > On 16 Apr 2017, at 12:36, Ian Clark wrote: > > Raul is right: there's no native concept of a "dictionary" in J. > > But dictionaries, as you see them used in Python & Swift, are alive and > well in J. They are employed by the J system itself for just the same > p

Re: [Jprogramming] Dictionary with Strings as Keys

2017-04-16 Thread Ian Clark
Raul is right: there's no native concept of a "dictionary" in J. But dictionaries, as you see them used in Python & Swift, are alive and well in J. They are employed by the J system itself for just the same purposes as Apple does. (Xcode users: I'm referring to NSDictionary and Property Lists (.pl

Re: [Jprogramming] Dictionary with Strings as Keys

2017-04-12 Thread Raul Miller
But that can only be an issue in certain contexts. One possible workaround, for some of those contexts, involves using sorted keys (and values) and using I. where i. was used in my quicky example. Other workarounds are also possible - but my point is that the details of why these things matter al

Re: [Jprogramming] Dictionary with Strings as Keys

2017-04-12 Thread bill lam
The dyad i. primitive contains optimizatins using hash and should perform much better than linear search, moreover j806 avx uses hardware crc32 as hash. I suspect simple dyad i. can out perform some dictionary implementations. Ср, 12 апр 2017, jprogramming написал(а): > One potential problem wit

Re: [Jprogramming] Dictionary with Strings as Keys

2017-04-12 Thread 'Jon Hough' via Programming
One potential problem with using two arrays, one for keys and one for values, is that lookup time increases by O(n), whereas it may be desirable for constant time lookup, or O(log n). E.g. it makes it difficult to implement some algorithms that require constant time lookup datastructures. On

Re: [Jprogramming] Dictionary with Strings as Keys

2017-04-12 Thread Raul Miller
The reason J does not implement dictionaries (and seems to be designed to discourage their use) has to do with how bad dictionaries can mangle your architecture. In my experience you usually want to find multiple different pieces of information when looking things up. With a dictionary approach th

Re: [Jprogramming] Dictionary with Strings as Keys

2017-04-12 Thread 'Jon Hough' via Programming
I created one a while ago. https://github.com/jonghough/msgpack-j/blob/master/hashmap.ijs This is a crude implementation of a hashmap, using separate chaining. Admittedly, it isn't particularly great. E.g. hashing function implementation isnt very good. It uses symbols to represent inner hashmaps

Re: [Jprogramming] Dictionary with Strings as Keys

2017-04-12 Thread 'Pascal Jasmin' via Programming
___ From: Herbert Weissenbaeck // Privat To: programm...@jsoftware.com Sent: Wednesday, April 12, 2017 8:34 AM Subject: [Jprogramming] Dictionary with Strings as Keys Next beginner's question: What would be an efficient/fast (or the recommended) J way to implement a dictionary

[Jprogramming] Dictionary with Strings as Keys

2017-04-12 Thread Herbert Weissenbaeck // Privat
Next beginner's question: What would be an efficient/fast (or the recommended) J way to implement a dictionary with strings as keys and arbitrary contents (nouns, verbs, boxes) as values, which allows inserting, removing, fetching and editing? Thank you. Sent from my iPhone