Burrows–Wheeler transform: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: simplified the code, eliminated the use of a subroutine.) |
|||
Line 741: | Line 741: | ||
$.7= "bad─bad thingy"'fd'x /* ◄─── this string can't be processed.*/ |
$.7= "bad─bad thingy"'fd'x /* ◄─── this string can't be processed.*/ |
||
end |
end |
||
⚫ | |||
do t=1 while $.t\='' |
do t=1 while $.t\=''; if t\==1 then say /*process each of the inputs (or input)*/ |
||
⚫ | |||
out= BWT($.t) /*invoke the BWT function, get result*/ |
out= BWT($.t) /*invoke the BWT function, get result*/ |
||
ori= iBWT(out) /* " " iBWT " " " */ |
ori= iBWT(out) /* " " iBWT " " " */ |
||
Line 754: | Line 753: | ||
BWT: procedure expose ?.; parse arg y,,$ /*obtain the input; nullify $ string. */ |
BWT: procedure expose ?.; parse arg y,,$ /*obtain the input; nullify $ string. */ |
||
?.1= 'fd'x; ?.2= "fc"x /*assign the STX and ETX strings. */ |
?.1= 'fd'x; ?.2= "fc"x /*assign the STX and ETX strings. */ |
||
do i=1 for 2 /* [↓] check for invalid input string.*/ |
|||
_= verify(y, ?.i, 'M'); if _==0 then iterate; er= '***error*** BWT: ' |
|||
⚫ | |||
⚫ | |||
⚫ | |||
end /*i*/ /* [↑] if error, perform a hard exit.*/ |
|||
⚫ | |||
y= ?.1 || y || ?.2 /*obtain the input; add a fence to it.*/ |
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.*/ |
L= length(y); m= L-1 /*get the length of new text; get L-1.*/ |
||
Line 769: | Line 769: | ||
end /*k*/ /* ··· the array's right─most character*/ |
end /*k*/ /* ··· the array's right─most character*/ |
||
return $ /*return the constructed answer. */ |
return $ /*return the constructed answer. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
|||
⚫ | |||
⚫ | |||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
iBWT: procedure expose ?.; parse arg y,,@. /*obtain the input; nullify @. string.*/ |
iBWT: procedure expose ?.; parse arg y,,@. /*obtain the input; nullify @. string.*/ |