Skip to content

ToLehmerCode

Entry i counts the later entries smaller than p(i).

ToLehmerCode(Permutation)

Domain: Combinatorial maps

Details
  • Takes a `Permutation` and returns a `SubexcedantSeq` — a typed map, so a wrong carrier is a type error rather than a wrong answer.
  • Its total is the inversion count, which is the Lehmer code's whole point.

Examples