math.transforms.bwt: adding inefficient versions of Burrows-Wheeler transform.
parent
4f3622849d
commit
9fe9437445
|
@ -0,0 +1 @@
|
||||||
|
John Benediktsson
|
|
@ -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
|
|
@ -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* ;
|
|
@ -0,0 +1 @@
|
||||||
|
Burrows-Wheeler Transform
|
Loading…
Reference in New Issue