Thank you very much for your reply. I get the general idea, but my problem is that I need to end up with an array of size @perms that has counts of each item from @perms that occur in @observed. The reason is that what I really will do is generate that coding for each of many words, generate the array giving the counts of observed patterns from the entire set of possible patterns, and then calculate similarity of those resulting vectors as an index of word similarity.
Your solution provides a hash with counts for each item in @observed, but then I need to associate those counts with the position of the corresponding element in @perms in @permCounts (or %permCounts!).
So if:
@observed = ("ab", "ab", "ad", "an", "bd", "bn", "dn");
and:
@perms = ("aa", "ab", "ac", "ad", "ae", "af", "ag", "an", "ba", "bd", "bh", "bn", "dn"); # @perms would never be something like this, # but just to give an example
Then the result I want is that @permCounts would be:
(0, 2, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1)
Thanks very much,
jimIn reply to Re^2: counting instances of one array in another array
by jsmagnuson
in thread counting instances of one array in another array
by jsmagnuson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |