Skip Menu |

This queue is for tickets about the Tree-Suffix CPAN distribution.

Report information
The Basics
Id: 18166
Status: resolved
Priority: 0/
Queue: Tree-Suffix

People
Owner: Nobody in particular
Requestors: ewijaya [...] singnet.com.sg
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Some Documentation/implementation issues on tree->string method and tree->find
Hi Gray, This two methods are really useful. Just few things. 1. I'm just wondering why the find method returns Array of Array, while I thought it would be much straightforward as simple array. Since the content is always 3 elements right? 2. In your documentation you said that: $tree->string(string_index) $tree->string(string_index, start) $tree->string(string_index, start, end) Returns the string at index_id. The start and end positions may be specified to return a substring. Actually the method returns the "reference" of the string. Please see my code below. Was that your initial intention? If so, wouldn't it be better if you return simple string instead? I'm using: Tree::Suffix version 0.12 perl, v5.8.5 built for i386-linux-thread-multi Linux localhost 2.6.8.1-12mdk #1 Fri Oct 1 12:53:41 CEST 2004 i686 Intel(R) Pentium(R) 4 CPU 2.80GHz unknown GNU/Linux __BEGIN__ use strict; use Data::Dumper; use Carp; use Tree::Suffix; my @strings = qw ( TTTTGGGGGGGGGGGGGGGGG ATCGGGGGACCGTTCTCTCCCC ); my $tree = Tree::Suffix->new(@strings); my $string = 'TTTT'; my @lcs = $tree->lcs; my @bool2 = $tree->find($string); print "BOOL\n"; print Dumper @bool2 ; print "Index: $bool2[0]->[0] \n"; print Dumper $tree->string(0,0,3); my @indices = $tree->strings; print Dumper \@indices ; __END__ Regards, Edward WIJAYA
From: gray [...] cpan.org
Show quoted text
> 1. I'm just wondering why the find method > returns Array of Array, while I thought > it would be much straightforward as simple array. > Since the content is always 3 elements right?
no, the list is always _multiples_ of 3. since perl iterators are lacking and you can't do something simple like for ($index, $start, $pos) $tree->find($string) as in python, this is the next best method. relying on the c-style loop for (my $i=0; $i<@matches-3; $i+=3) is begging for indexing errors. Show quoted text
> 2. In your documentation you said that: > $tree->string(string_index) > $tree->string(string_index, start) > $tree->string(string_index, start, end) > > Returns the string at index_id. The start and end positions may be > specified to return a substring. > > Actually the method returns the "reference" of the string. > Please see my code below. Was that your initial intention? > If so, wouldn't it be better if you return simple string > instead?
actually it doesn't. running your test produces: BOOL $VAR1 = [ 0, 0, 3 ]; Index: 0 $VAR1 = 'TTTT'; $VAR1 = [ 0, 1 ]; a reference to a string would look like: $VAR1 = \'TTTT' take a look at my test files for examples.
Subject: Re: [rt.cpan.org #18166] Some Documentation/implementation issues on tree->string method and tree->find
Date: Wed, 15 Mar 2006 08:58:43 +0800 (SGT)
To: bug-Tree-Suffix [...] rt.cpan.org
From: Edward Wijaya <ewijaya [...] singnet.com.sg>
You are right, Gray. Truly apologize for my negligence. --Edward --- gray via RT <bug-Tree-Suffix@rt.cpan.org> wrote: Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=18166 > >
> > 1. I'm just wondering why the find method > > returns Array of Array, while I thought > > it would be much straightforward as simple array. > > Since the content is always 3 elements right?
> > no, the list is always _multiples_ of 3. since perl iterators are > lacking and you can't do something simple like > for ($index, $start, $pos) $tree->find($string) > as in python, this is the next best method. relying on the c-style > loop > for (my $i=0; $i<@matches-3; $i+=3) > is begging for indexing errors. >
Show quoted text
> > 2. In your documentation you said that: > > $tree->string(string_index) > > $tree->string(string_index, start) > > $tree->string(string_index, start, end) > > > > Returns the string at index_id. The start and end positions may be
>
> > specified to return a substring. > > > > Actually the method returns the "reference" of the string. > > Please see my code below. Was that your initial intention? > > If so, wouldn't it be better if you return simple string > > instead?
> > actually it doesn't. running your test produces: > > BOOL > $VAR1 = [ > 0, > 0, > 3 > ]; > Index: 0 > $VAR1 = 'TTTT'; > $VAR1 = [ > 0, > 1 > ]; > > > a reference to a string would look like: $VAR1 = \'TTTT' > take a look at my test files for examples. >