String::Eertree - Build the palindromic tree aka Eertree for a string
Version 0.03
Eertrees make it possible to find palindrome substrings of a string in a very fast way.
use String::Eertree; my $tree = 'String::Eertree'->new(string => 'referee'); my @palindromes = $tree->uniq_palindromes; # r e f efe refer ere ee
To see how fast it is, check the file examples/rosetta-code.pl. It compares the speed of the Eertree algorithm to a naive generation of all the unique palindromes as found at Rosetta Code. Eertree is almost 40 times faster on a string of length 79.
'String::Eertree'->new(string => 'xxx')
The constructor. Use the named argument string to specify the string you want to analyse.
string
my $string = $tree->string;
The original string the tree was constructed from (see above).
my @palindromes = $tree->uniq_palindromes;
Returns all distinct palindrome substrings of the string.
my @palindromes = $tree->palindromes;
Returns all the palindrome substrings of the string, each substring can be repeated if it's present at different positions in the string.
E. Choroba, <choroba at cpan.org>
<choroba at cpan.org>
Please report any bugs or feature requests to bug-string-eertree at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=string-eertree. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-string-eertree at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc String::Eertree
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=string-eertree
Search CPAN
https://metacpan.org/release/string-eertree
Thanks Mohammad S Anwar (MANWAR) for introducing me to the idea.
Thanks shubham2508 for a clean Python implementation.
Thanks Mikhail Rubinchik and Arseny M. Shur for inventing the eertree (arXiv:1506.04862v2 [cs.DS] 17 Aug 2015).
This software is Copyright (c) 2022-2023 by E. Choroba.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install String::Eertree, copy and paste the appropriate command in to your terminal.
cpanm
cpanm String::Eertree
CPAN shell
perl -MCPAN -e shell install String::Eertree
For more information on module installation, please visit the detailed CPAN module installation guide.