Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Burrows-Wheeler transform

by shi (Novice)
on Jul 01, 2008 at 17:48 UTC ( #694989=snippet: print w/ replies, xml ) Need Help??

Description: As told by wikipedia the one in the title is a transform useful when compressing data. I spent some minutes on writing these snippets for direct and inverse transformation. May any wise monk help shrinking the code, I'd be thankful and glad to see the results :)
$/="";$l=length($w=<>);map{print+chop}sort+map{substr"$w\0$w",$_,$l+1}
+0..$l

push@w,split//for<>;map{@_=sort@_;$_[$_]=$w[$_].$_[$_]for+0..$#w}0..$#
+w;print+grep{s/\0$//}@_
Comment on Burrows-Wheeler transform
Download Code
Replies are listed 'Best First'.
Re: Burrows-Wheeler transform
by moritz (Cardinal) on Jul 01, 2008 at 17:58 UTC
    Unless you're trying to golf, you should strive to make it more readable, not shorter.
      You're right, but I was actually making also a try at golf.
      -- 
      @_=(115,-17,6);print+map{chr$_[$.=$_-$_]*$_**$.+++$_[$.]*$_**$.+++$_[$.]*$_**$.}$.-$...$#_

Back to Snippets Section

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://694989]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2015-07-30 09:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls