Okay... so my boss has a hash of lists that includes a hash as one member of that list. That hash is of lists that also include a reference to a list. Now I need to get that last list to actually be made, instead of scalars, of another list of hashes that key to a bunch of lists...
whee...
This is hurting my brain.
whee...
This is hurting my brain.
no subject
Date: 2002-04-04 02:17 pm (UTC)no subject
Date: 2002-04-08 11:27 am (UTC)Well, actually recursion has made the filling in of the layered structures a much easier piece of code to understand, stand-alone.
It's just the whole wrapping of code that I didn't write around a seven-dimensional problem that's hurting my brain[
no subject
Date: 2002-04-04 05:42 pm (UTC)I think I see what the core problem is, here: you have a associative index that's a mutable. That's just a straight up design no-no (in part, because you have to rehash on any change of the index list). I'm hoping that I'm misunderstanding the problem, because if Perl lets you do that, my opinion of it will drop even lower than its current "mitachondria of shit-eating dung beetles" level.
no subject
Date: 2002-04-04 05:50 pm (UTC)no subject
Date: 2002-04-04 06:00 pm (UTC)OK, in a real language. [smirk]
Seriously, its just an associative array; walking that kind of structure should be a total no brainer as long as you just keep a separate reference to the index and what it points to.
no subject
Date: 2002-04-08 08:41 am (UTC)So it's actually a hash with a string key that associates to a reference to an array. The array (which could just be thought of as an object if my boss had been object oriented instead of perl-oriented) has a reference to another hash that keys off a string that is associated to a reference to an array. That array, presently, is just an array of strings, which is nice, but I'm just having to munge it up by making it an array of references to yet another hash of string keys associated to a reference of arrays.
I actually kind of like the fact that I can use a hash/library/keyed index that is mutable, i.e. I can stuff things into it whenever I want to and query by keys when I need to as I'm having to parse a file to figure out what the new members even might be. I can think in objects when I think of them as objects that happen to have references to other objects, in order to represent what's presently a four dimensional array of possibliites which I have to expand to seven. It's translating what was originally a pretty tough problem into a language I don't know was what was hurting my brain, I think.
no subject
Date: 2002-04-08 12:24 pm (UTC)So, what you have looks vaguely like this:
In most languages I deal with on any regular basis, one ends up conflating the Array and Hash idea; Python Dictionaries are associative arrays that can point off at each other, like so:
X = {'item': 'value'} Y = {'thing': 'value2} Y = {1: X, 2: Y}And then you can access them like so:
... if you wanted to refer down the whole chain. Of course, you could use full-bore objects at any step down the chain (which are really represented behind the scenes as a Dictionary, internally, regardless).
Dictionaries and their kin are wonderful, wonderful tools that let you do scary things like count the number of occurances of an item in a file in linear time and other such goodies. I dig 'em. :)
no subject
Date: 2002-04-08 02:17 pm (UTC)Exactly. I originally got at dictionaries through SmallTalk and, yes, the hashes are exactly that. I like 'em, yum! It's just getting my brain around someone else's code in an unfamiliar language that's been mildly hairy.
no subject
Date: 2002-04-08 04:46 pm (UTC)Fully functional red/black and b-trees, yum ...