Update: My original post read X < Y; this was incorrect, and has been corrected to X > Y.

G'day learned monks,

In some of my recent work I needed to develop a fast and compact way of encoding information between pairs of entries in an list, where the tail of that list may grow (but never shrink) over time, and the ordering of the list otherwise remains fixed.

The resulting encoding states that information about the pair (X,Y) is stored in location X(X-1)/2 + Y where X > Y, and indexes start from zero. In my case I'm using this to index bitstrings, but it's equally valid for use in arrays.

My trouble is that I know that this is not a new encoding scheme, since the most modest amount of thought on the subject reveals it as an answer. Unfortunately, I'm having a hard time finding its true name, and hence whether there is an existing module on the CPAN, or if this is a candidate for a CPAN release.

Please note that this is a rather academic question about finding correct attribution and prior work, not one about implementation.

Many thanks,


In reply to Extendable pairwise indexes - prior work? by pjf

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.