Burrows–Wheeler transform: Difference between revisions

m
→‎{{header|REXX}}: simplified the code, eliminated the use of a subroutine.
m (→‎{{header|REXX}}: simplified the code, eliminated the use of a subroutine.)
Line 741:
$.7= "bad─bad thingy"'fd'x /* ◄─── this string can't be processed.*/
end
if t\==1 then say /*insert a[↑] show blank line between outputs. */
 
do t=1 while $.t\=''; if t\==1 then say /*process each of the inputs (or input)*/
if t\==1 then say /*insert a blank line between outputs. */
out= BWT($.t) /*invoke the BWT function, get result*/
ori= iBWT(out) /* " " iBWT " " " */
Line 754 ⟶ 753:
BWT: procedure expose ?.; parse arg y,,$ /*obtain the input; nullify $ string. */
?.1= 'fd'x; ?.2= "fc"x /*assign the STX and ETX strings. */
do i=1 for 2 /* [↓] check for invalid input string.*/
loc_= verify(y, ?.i, 'M'); if _==0 then iterate; er= /'***error***look for invalidBWT: character in input. */'
BWTer: er= '***error*** BWT: '; say er "invalid input: " y
if loc\==0 then call BWTer /*there an " " " " ? */
say er 'The input string contains an invalid character at position' loc_"."; exit 13
end /*i*/ /* [↑] if error, perform a hard exit.*/
end if loc\==0 /*i*/ then call BWTer /*there an " "/* [↑] if error, " "perform a ?hard exit.*/
y= ?.1 || y || ?.2 /*obtain the input; add a fence to it.*/
L= length(y); m= L-1 /*get the length of new text; get L-1.*/
Line 769:
end /*k*/ /* ··· the array's right─most character*/
return $ /*return the constructed answer. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
BWTer: er= '***error*** BWT: '; say er "invalid input: " y
say er 'The input string contains an invalid character at position' loc"."; exit 13
/*──────────────────────────────────────────────────────────────────────────────────────*/
iBWT: procedure expose ?.; parse arg y,,@. /*obtain the input; nullify @. string.*/