Skip Menu |

This queue is for tickets about the FLAT CPAN distribution.

Report information
The Basics
Id: 117074
Status: open
Priority: 0/
Queue: FLAT

People
Owner: Nobody in particular
Requestors: user42_kevin [...] yahoo.com.au
Cc:
AdminCc:

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



Subject: difference() when different alphabets
Date: Sat, 20 Aug 2016 12:36:05 +1000
To: bug-FLAT [...] rt.cpan.org
From: Kevin Ryde <user42_kevin [...] yahoo.com.au>
With FLAT 0.9.1 I was tricked by difference() on some strings like use strict; use FLAT; my $f = FLAT::Regex->new('foo | bar')->as_dfa; my $t = FLAT::Regex->new('foo ')->as_dfa; $f = $f->difference($t); print $f->is_empty ? "empty\n" : "not empty\n"; print $f->contains('bar') ? "contain bar\n" : "no contains bar\n"; This prints "empty" whereas at first I thought foo+bar subtract foo might leave bar. I see this happens because the alphabet in $f and $t are not the same. Maybe the docs could caution that difference() should have alphabet of $t at least as big as $f, otherwise the complement() part means you lose the extras in $f. Maybe another flavour of difference, with a new method name, could allow for symbols of $f not appearing in $t. Dunno exactly how, extend the alphabet of $t or something.
On Fri Aug 19 22:39:31 2016, user42_kevin@yahoo.com.au wrote: Show quoted text
> With FLAT 0.9.1 I was tricked by difference() on some strings like > > use strict; > use FLAT; > my $f = FLAT::Regex->new('foo | bar')->as_dfa; > my $t = FLAT::Regex->new('foo ')->as_dfa; > $f = $f->difference($t); > print $f->is_empty ? "empty\n" : "not empty\n"; > print $f->contains('bar') ? "contain bar\n" : "no contains bar\n"; > > This prints "empty" whereas at first I thought foo+bar subtract foo > might leave bar. I see this happens because the alphabet in $f and $t > are not the same. > > Maybe the docs could caution that difference() should have alphabet of > $t at least as big as $f, otherwise the complement() part means you lose > the extras in $f. > > Maybe another flavour of difference, with a new method name, could allow > for symbols of $f not appearing in $t. Dunno exactly how, extend the > alphabet of $t or something.
thank you, will look into it