Index finite lists of positive integers: Difference between revisions

Line 598:
changes would be required if using jaq as jaq does not (as of this writing in 2024) support
the `include` or `module` directives.
===Fibonacci-Bijective map based on Fibonacci encoding===
<syntaxhighlight lang="jq">
include "fibonacci" {search: "./"}; # see https://rosettacode.org/wiki/Category:Jq/fibonacci.jq
Line 607:
map(fibencode | map(tostring) | join(""))
| join("")
| explode | reverse[1:] | implode ;
 
def unrank:
"1" + tostring
tostring | explode | reverse | implode
| split("11")
| .[:-1]
Line 661 ⟶ 662:
50544
],
"encoded": 10000010101010101010000110010010100010100100011100101000010100010100111001000010010010000100110010001001010010101011100000001000000000010111000101001010010101000101101001000010001001000001100010001000100000000001110000100100000010001000011000010101001000001001,
"encoded": 110000010101010101010000110010010100010100100011100101000010100010100111001000010010010000100110010001001010010101011100000001000000000010111000101001010010101000101101001000010001001000001100010001000100000000001110000100100000010001000011000010101001000001001,
"check": true
}
2,472

edits