Reinhold May wrote:
> 
> This is probably mainly going to Flavio:
> 
> I've tried a different approach to solving my problem  described
> in earlier posts and this time I have the following issue:
> 
>    If I do an intersection (whether  with  iterator->next($span)
> or $spanset->intersection($span) or even
> $spanset->as_list($span)),  I  get  a  SpanSet  that  can  have,
> depending on where the intersection span starts and ends, a  cut
> first span and a cut last span:
> 
>    |----|  |----|  |----|  |----|  # Source SpanSet
>      |----------------|            # intersection Span
> 
>      |--|  |----|  |--|            # Resulting SpanSet
> 
> what I actually need is a set of unmodified spans intersected by
> that span:
> 
>    |----|  |----|  |----|          # Wanted resulting SpanSet
> 
> I  do  understand  that  this  behaviour  is  wanted   by   some
> applications but in mine, I can't use the resulting spanset.
> 
>    One solution to my problem would be to check  the  first  and
> the last Span in my resulting SpanSet for its length and correct
> it when necessary. But I find that solution rather ugly.

Using the not-yet-available grep:

  my $new_set = $spanset->set_grep(
      sub { $_[0]->intersects( $span ) }
  );

- Flavio S. Glock

Reply via email to