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

10 lines
341 B
Text
Raw Permalink Normal View History

2016-12-05 23:44:36 +01:00
("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