Index finite lists of positive integers: Difference between revisions
Content added Content deleted
m (→base 11: removed errant tag) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 24: | Line 24: | ||
Make the ''rank'' function as a [[wp:bijection| <u>bijection</u>]] and show ''unrank(n)'' for <big>'''n'''</big> varying from '''0''' to '''10'''. |
Make the ''rank'' function as a [[wp:bijection| <u>bijection</u>]] and show ''unrank(n)'' for <big>'''n'''</big> varying from '''0''' to '''10'''. |
||
<br><br> |
<br><br> |
||
=={{header|11l}}== |
|||
{{trans|Python}} |
|||
<lang 11l>F rank(x) |
|||
R BigInt(([1] [+] x).map(String).join(‘A’), radix' 11) |
|||
F unrank(n) |
|||
V s = String(n, radix' 11) |
|||
R s.split(‘A’).map(Int)[1..] |
|||
V l = [1, 2, 3, 10, 100, 987654321] |
|||
print(l) |
|||
V n = rank(l) |
|||
print(n) |
|||
l = unrank(n) |
|||
print(l)</lang> |
|||
{{out}} |
|||
<pre> |
|||
[1, 2, 3, 10, 100, 987654321] |
|||
1723765384735274025865314 |
|||
[1, 2, 3, 10, 100, 987654321] |
|||
</pre> |
|||
=={{header|D}}== |
=={{header|D}}== |