Thanks, I'll take a look at those. Paul
On 21 February 2017 at 14:19, Joe Bogner <[email protected]> wrote: >> In a traditional language, I'd have a mapping - something like the >> following pseudo-code. >> >> result = {} >> do 1000000 times: >> newval = verb() >> result[newval] = result[newval] + 1 # Needs a special case for the >> first time we see a value. > > OK, it sounds like you're looking for a hashmap/hashtable/associative > array/dictionary > > Here is one implementation in J: > > https://github.com/jonghough/msgpack-j/blob/master/hashmap.ijs > > > Or http://code.jsoftware.com/wiki/Essays/DataStructures#Associative_Array > > > > On Tue, Feb 21, 2017 at 8:41 AM, Paul Moore <[email protected]> wrote: > >> On 21 February 2017 at 13:23, Joe Bogner <[email protected]> wrote: >> >> >> >> The key thing here is that I'm going to be collecting millions of >> >> results, and I'll run out of memory if I just retain them all and >> >> count at the end. But I'm not sure how to modify structures in J. >> >> >> > >> > Are you sure you will run out of memory? I can hold a billion ints on my >> > machine and use 7.8gb of memory. >> >> I did yesterday. I can't recall the details - I may have been running >> a billion simulations. I may well also have been using a >> memory-inefficient approach, though (if I held 5 numbers for each run, >> that would be 40GB of RAM I guess). >> >> My purpose behind this exercise is that I'm trying to demonstrate to a >> friend that you don't need to write custom C programs (which is what >> he did) to do this type of work, and that off the shelf (albeit >> specialised) languages can cope fine (where "fine" means "comparable >> to custom C"). So far, I'm finding that's not true - my experiments >> with various languages[1] have either been too slow or too memory >> hungry to make my case. When a tiny performance issue or over-use of >> memory in the implementation of the single experiment gets multiplied >> by factors on the order of millions or billions, that doesn't scale >> well enough. >> >> It's an interesting exercise that's got me learning a lot about >> various languages' strengths and weaknesses, though :-) >> >> Paul >> >> [1] Most of which have been at the "interested beginner" level, as here. >> ---------------------------------------------------------------------- >> 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
