math.transforms.bwt: adding inefficient versions of Burrows-Wheeler transform.

db4
John Benediktsson 2012-09-09 11:38:59 -07:00
parent 4f3622849d
commit 9fe9437445
4 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1 @@
John Benediktsson

View File

@ -0,0 +1,6 @@
! Copyright (C) 2012 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: strings tools.test ;
IN: math.transforms.bwt
{ "asdf" } [ "asdf" bwt ibwt >string ] unit-test

View File

@ -0,0 +1,15 @@
! Copyright (C) 2012 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: arrays fry kernel math sequences sequences.extras
sorting ;
IN: math.transforms.bwt
! Inefficient versions of Burrows-Wheeler Transform
: bwt ( seq -- newseq )
{ 0 } swap append all-rotations natural-sort [ last ] map ;
: ibwt ( newseq -- seq )
[ length [ { } <array> ] keep ] keep
'[ _ [ prefix ] 2map natural-sort ] times
[ { 0 } tail? ] find nip 1 head* ;

View File

@ -0,0 +1 @@
Burrows-Wheeler Transform