Index finite lists of positive integers: Difference between revisions

m
added a ;Task: section header, added whitespace and bullets to the task's preamble..
m (→‎{{header|REXX}}: added comments, added whitespace, used more decimal digits and a bigger integer, added wording to the REXX section header..)
m (added a ;Task: section header, added whitespace and bullets to the task's preamble..)
Line 1:
{{draft task}}
 
It is known that the set of finite lists of positive integers is &nbsp; [[wp:countable| <u>countable</u>)]]. This means that there exists a subset of natural integers which can be mapped to the set of finite lists of positive integers. The purpose of this task is to implement such a mapping :
 
*This writemeans that there exists a functionsubset ''rank''of natural integers which assignscan anbe integermapped to anythe finite,set arbitrarilyof longfinite listlists of arbitrary largepositive integers.
 
* write a function ''unrank'' which is ''rank'' 's [[wp:inverse function|inverse function]].
 
;Task:
<br>Demonstrate your solution by picking a random-length list of random positive integers, turn it into an integer and get the list back.
Implement such a mapping:
:* &nbsp; write a function &nbsp;''rank''&nbsp; which assigns an integer to any finite, arbitrarily long list of arbitrary large positive integers.
:* &nbsp; write a function &nbsp; ''unrank'' &nbsp; which is the &nbsp; ''rank'' 's&nbsp; [[wp:inverse function| <u>inverse function</u>]].
 
There are many ways to do this. Feel free to choose any one you like.
 
Demonstrate your solution by:
<br>Demonstrate:* your solution by&nbsp; picking a random-length list of random positive integers, turn it into an integer and get the list back.
:* &nbsp; turn it into an integer, &nbsp; and
:* &nbsp; get the list back.
 
'''Extra credit''':
 
There are many ways to do this. &nbsp; Feel free to choose any one you like.
Make rank as a [[wp:bijection|bijection]] and show unrank(n) for n varying from 0 to 10.
 
 
''';Extra credit''':
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>