RosettaCodeData/Task/Move-to-front-algorithm/Jq/move-to-front-algorithm-2.jq

10 lines
341 B
Plaintext

("abcdefghijklmnopqrstuvwxyz" | explode) as $ST
| ("broood", "bananaaa", "hiphophiphop")
| . as $string
| m2f_encode($ST)
| . as $encoded
| m2f_decode($ST) as $decoded
| if $string == $decoded then "\($string) => \($encoded) => \($decoded)"
else "INTERNAL ERROR: encoding of \($string) => \($encoded) => \($decoded)"
end