Holy obfuscation, Batman!

That seems to work. You could choose to use that (and hopefully leave a comment above it in your script). But you can get rid of some cruft there.

First, as mentioned before, the dummy dim on $b is arbitrary. Using xchg when you already got to pick the dims is silly.
which( maximum( ($a->dummy == $b) ) != 0)
Maximum is a good choice. Like summation, it folds over a dimension in a way that works like logical or. But the inequality is unnecessary. All non-zero values are true. which already handles this.
which( maximum( $a->dummy == $b ) )
Thats about as good as any solutions I could give you. You'll still need a comment, but its a little easier on the eyes.

For comparison purposes, here's the solutions I was expecting:
# The one I basically handed you. Catches duplicates. $c = which( $a == $b->dummy ) % $a->dim(0); # Switching up the dims. Basically same as above. $c = which( $a->dummy == $b ) / $b->dim(0); # Using summation. Like yours, ignores duplicates. $c = which( sumover( $a->dummy == $b ) );
They are no more understandable than your solution (once trimmed).

In reply to Re^5: matching pdl elements by plobsing
in thread matching pdl elements by Anonymous Monk

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.