Index finite lists of positive integers: Difference between revisions
Index finite lists of positive integers (view source)
Revision as of 09:24, 12 November 2021
, 2 years agoAdded 11l
m (→base 11: removed errant tag) |
Alextretyak (talk | contribs) (Added 11l) |
||
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'''.
<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}}==
|