Index finite lists of positive integers: Difference between revisions

Added 11l
m (→‎base 11: removed errant tag)
(Added 11l)
Line 24:
Make the &nbsp; ''rank'' &nbsp; function as a &nbsp; [[wp:bijection| <u>bijection</u>]] &nbsp; and show &nbsp; ''unrank(n)'' &nbsp; for &nbsp; <big>'''n'''</big> &nbsp; varying from &nbsp; '''0''' &nbsp; to &nbsp; '''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}}==
1,480

edits