Oh, wow! I've never heard of PDL. This is spiffy as all get out. Okay, here's how I'd go about it. . .
#here's an array my @a = (1,2,3); #now it's a string: my $string = join '', @a; #here's another array my @b; #Now the array values your looking for become an array element. #Increment when those values come up again. $b[$string]++; # so $b[123] now = 1 #Leading zeroes disappear, so you could add a 1 to the front of $strin +g. $string = '1' . join '', @a; $b[$string]++; # so $b[1123] now = 1 #yeah. that'll work #I might write the whole thing as: my @a = all your stuff as little array refs from wherever my @b = the answers you want; for (@a) my $string = '1' . join '', @$_; $b[$string]++ } #after that, you could copy to an array of tuples: # e.g., $c[2] = (["123"],[5]); #strip that extra '1' and turn to strin +g? # $c[2] = (["info"], [number of times you find it]); # might make it easier to play with. #would %b be faster than @b? I prefer arrays, but that's my bias. #$b{$string}++ would certainly work. But, is it as easy to muck about +with? #that extra '1' for referencing the elements does bother me a bit.
$state{tired}?sleep(40):eat($food);

In reply to Re: Counting PDL vectors in a PDL matrix by corenth
in thread Counting PDL vectors in a PDL matrix by mxb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.