Anonymous user
Burrows–Wheeler transform: Difference between revisions
m
→{{header|REXX}}: added whitespace.
SqrtNegInf (talk | contribs) (Added Perl example) |
m (→{{header|REXX}}: added whitespace.) |
||
Line 498:
/*──────────────────────────────────────────────────────────────────────────────────────*/
BWT: procedure expose ?.; parse arg y,,$ /*obtain the input; nullify $ string. */
?.1= 'fd'x;
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);
@.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
_= @.j; @.j= @.k;
end /*j*/
end /*m*/; return</lang>
|