Jump to content

Burrows–Wheeler transform: Difference between revisions

m
→‎{{header|REXX}}: added whitespace.
(Added Perl example)
m (→‎{{header|REXX}}: added whitespace.)
Line 498:
/*──────────────────────────────────────────────────────────────────────────────────────*/
BWT: procedure expose ?.; parse arg y,,$ /*obtain the input; nullify $ string. */
?.1= 'fd'x; ?.2="fc"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') /*look for invalid character in input. */
Line 504:
end /*i*/ /* [↑] if error, perform a hard exit.*/
y= ?.1 || y || ?.2 /*obtain the input; add a fence to it.*/
L= length(y); m= L-1 m= L-1 /*get the length of new text; get L-1.*/
@.1= y /*define the first element of the table*/
do j=2 for m; _= j-1 /*now, define the rest of the elements.*/
Line 532:
cSort: procedure expose @.; parse arg n; m=n-1 /*N: is the number of @ array elements.*/
do m=m for m by -1 until ok; ok=1 /*keep sorting the @ array until done.*/
do j=1 for m; k= j+1; if @.j<<=@.k then iterate /*elements in order? */
_= @.j; @.j= @.k; @.k= _; ok= 0 /*swap two elements; flag as not done.*/
end /*j*/
end /*m*/; return</lang>
Cookies help us deliver our services. By using our services, you agree to our use of cookies.