Index finite lists of positive integers: Difference between revisions

(note about the many ways to solve the task)
Line 125:
 
=={{header|J}}==
 
'''Explicit version'''
 
Implementation:
Line 152 ⟶ 154:
 
Whether this is an efficient representation or not depends, of course, on the nature of the list being represented.
 
 
'''Tacit version'''
 
Implementation:
 
<lang j> rank =. 11&#.@:>@:(,&:>/)@:(<@:(10&,)@:(10&#.^:_1)"0)@:x:
unrank=. 10&#.;._1@:(11&#.^:_1)</lang>
 
Example use:
 
<lang J> rank 1 2 3 10 100 987654321 135792468107264516704251 7x
10859468893418553562739357752202339093235635587121336
unrank 10859468893418553562739357752202339093235635587121336x
1 2 3 10 100 987654321 135792468107264516704251 7</lang>
 
=={{header|Perl 6}}==
Anonymous user