Jump to content

Burrows–Wheeler transform: Difference between revisions

Added Factor
m (→‎{{header|REXX}}: added whitespace.)
(Added Factor)
Line 142:
--> ERROR: String can't contain STX or ETX
-->
</pre>
 
=={{header|Factor}}==
Factor has a Burrows-Wheeler transform implementation in its standard library. In addition to the transformed sequence, the <code>bwt</code> word also outputs an index for use with the inverse <code>ibwt</code> word.
<lang factor>USING: formatting io kernel math.transforms.bwt sequences ;
{
"banana" "dogwood" "TO BE OR NOT TO BE OR WANT TO BE OR NOT?"
"SIX.MIXED.PIXIES.SIFT.SIXTY.PIXIE.DUST.BOXES"
} [
[ print ] [ bwt ] bi
2dup " bwt-->%3d %u\n" printf
ibwt " ibwt-> %u\n" printf nl
] each</lang>
{{out}}
<pre>
banana
bwt--> 3 "nnbaaa"
ibwt-> "banana"
 
dogwood
bwt--> 1 "odoodwg"
ibwt-> "dogwood"
 
TO BE OR NOT TO BE OR WANT TO BE OR NOT?
bwt--> 36 "OOORREEETTRTW BBB ATTT NNOOONOO? "
ibwt-> "TO BE OR NOT TO BE OR WANT TO BE OR NOT?"
 
SIX.MIXED.PIXIES.SIFT.SIXTY.PIXIE.DUST.BOXES
bwt--> 29 "TEXYDST.E.IXIXIXXSSMPPS.B..E.S.EUSFXDIIOIIIT"
ibwt-> "SIX.MIXED.PIXIES.SIFT.SIXTY.PIXIE.DUST.BOXES"
</pre>
 
1,827

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.