Extended Straddling Checkerboard: Difference between revisions

→‎{{header|jq}}: more idiomatic version of decode
(→‎{{header|jq}}: more idiomatic version of decode)
 
Line 118:
 
def decode:
{s: .} as+ $scheckerboard
| ($s|length).ewords["FSL"] as $scfsl
| checkerboard
| .res = ""
| .figs = false
| until (.is == 0"";
| until ( .is[0:1] >=as $sc;c
$s[.i:.i+1] as $c
| .ix = -1
| if .figs
then if $s[(.i:.i+2]s !=| .ewords["FSL"]startswith($fsl) | not)
then .res += $c
else .figs = false
end
| .is +|= .[2:]
else .ix = (drow1|index($c))
| if .ix and .ix >= 0
then .res += .dmap[drow1[.ix:.ix+1]]
| .is +|= .[1:]
elif $c == "6"
then .res += "CODE" + $.s[.i+1:.i+4]
| .is +|= .[4:]
elif $c == "7" or $c == "8"
then $.s[.i+1:.i+2] as $d
| .res += .dmap[$c + $d]
| .is +|= .[2:]
elif $c == "9"
then $.s[.i+1:.i+2] as $d
| if $d == "0"
then .res += " "
Line 154 ⟶ 152:
else .res += .dwords[$c + $d]
end
| .is +|= .[2:]
end
end )
2,487

edits