in reply to Re: Element Count from Array to HoH
in thread Element Count from Array to HoH

Hi Ivancho,
Q: Perhaps you ought to be increasing {TTAT}{I1}, ie {$item2}{$tid}
A: I can't do that, cause it will miss counting "TTTT". if what you mean is changing them to this:
$$transaction_map_ref{$item2}{$tid}++;
Q:or possibly {TTTT}{I2}?
A:I don't get what you mean by that. What's the difference with the above statement.
Sorry..I'm rather slow here..
Q:can you have repeated elements in your array, and if so, what should be the behaviour?
A: Yes if that's the case, as long as condition "hd<=$d", they should be counted.
I hope that clarifies the problem.
Regards,
Edward

Replies are listed 'Best First'.
Re^3: Element Count from Array to HoH
by ivancho (Hermit) on May 26, 2005 at 07:56 UTC
    Yeah, my bad, I only meant {TTTT}{I2} - which is what my code does, I shouldn't have asked about {TTAT}{I1}..

    My understanding is as follows. You get a pair "TTAT", "I2", and you say to yourself 'But this TTAT might actually be TTTT - so let's increase {TTTT}{I2} for good measure.. We'll increase {TTAT}{I2} too, when we get there...'

    If this is what you want to do, then my snippet should work fine.. The {map {(split)... line saves the unique 4 letter codes we have. Then for each line '$tid $item',
    grep {hd($item,$_) <= $d} keys %$trans_map_ref
    gives us which of our 4 letter codes $item might be. For each of them, we increase their {$tid} field.

    I think the problem here is that your function tries to do everything at once.. Maybe you can split it in 2 pieces - first find all pairs of neighbours between the 4 letter codes, then go through your array and for every item with a tid, also increase this tid for it's neighbours..

    hopefully this isn't just more mud...