line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dallycot::Value::ClosedRange; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:JSMITH'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# ABSTRACT: A finite range of integers |
5
|
|
|
|
|
|
|
|
6
|
23
|
|
|
23
|
|
17162
|
use strict; |
|
23
|
|
|
|
|
44
|
|
|
23
|
|
|
|
|
723
|
|
7
|
23
|
|
|
23
|
|
87
|
use warnings; |
|
23
|
|
|
|
|
32
|
|
|
23
|
|
|
|
|
463
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# No RDF equivalent - finite list of items |
10
|
|
|
|
|
|
|
|
11
|
23
|
|
|
23
|
|
78
|
use utf8; |
|
23
|
|
|
|
|
35
|
|
|
23
|
|
|
|
|
100
|
|
12
|
23
|
|
|
23
|
|
414
|
use parent 'Dallycot::Value::Collection'; |
|
23
|
|
|
|
|
28
|
|
|
23
|
|
|
|
|
114
|
|
13
|
|
|
|
|
|
|
|
14
|
23
|
|
|
23
|
|
1183
|
use Promises qw(deferred); |
|
23
|
|
|
|
|
32
|
|
|
23
|
|
|
|
|
114
|
|
15
|
|
|
|
|
|
|
|
16
|
23
|
|
|
23
|
|
4394
|
use Readonly; |
|
23
|
|
|
|
|
41
|
|
|
23
|
|
|
|
|
16085
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Readonly my $FIRST => 0; |
19
|
|
|
|
|
|
|
Readonly my $LAST => 1; |
20
|
|
|
|
|
|
|
Readonly my $DIRECTION => 2; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub as_text { |
23
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
return $self->[$FIRST]->as_text . ".." . $self->[$LAST]->as_text; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub calculate_length { |
29
|
0
|
|
|
0
|
0
|
|
my ( $self, $engine ) = @_; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $diff = $self->[$LAST]->value - $self->[$FIRST]->value; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return Dallycot::Value::Numeric->new( $diff->babs + 1 ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
0
|
0
|
|
sub is_defined { return 1 } |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
0
|
|
sub is_empty {return} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub calculate_reverse { |
41
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $d = deferred; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$d->resolve( bless [ $self->[$LAST], $self->[$FIRST], -$self->[$DIRECTION] ] => __PACKAGE__ ); |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return $d->promise; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
0
|
|
|
sub _type { return 'Range' } |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub head { |
53
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $d = deferred; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$d->resolve( $self->[$FIRST] ); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
return $d->promise; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub tail { |
63
|
0
|
|
|
0
|
0
|
|
my ( $self, $engine ) = @_; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
return $self->[$FIRST]->is_equal( $engine, $self->[$LAST] )->then( |
66
|
|
|
|
|
|
|
sub { |
67
|
0
|
|
|
0
|
|
|
my ($f) = @_; |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
if ($f) { |
70
|
0
|
|
|
|
|
|
return Dallycot::Value::EmptyStream->new(); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
0
|
|
|
|
|
|
my $next_p; |
74
|
0
|
0
|
|
|
|
|
if ( $self->[$DIRECTION] > 0 ) { |
75
|
0
|
|
|
|
|
|
$next_p = $self->[$FIRST]->successor; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else { |
78
|
0
|
|
|
|
|
|
$next_p = $self->[$FIRST]->predecessor; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
$next_p->then( |
81
|
|
|
|
|
|
|
sub { |
82
|
0
|
|
|
|
|
|
my ($next) = @_; |
83
|
0
|
|
|
|
|
|
return bless [ $next, $self->[$LAST], $self->[$DIRECTION] ] => __PACKAGE__; |
84
|
|
|
|
|
|
|
} |
85
|
0
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
0
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub _walk_tail { |
92
|
0
|
|
|
0
|
|
|
my ( $self, $engine, $d, $count ) = @_; |
93
|
|
|
|
|
|
|
|
94
|
0
|
0
|
|
|
|
|
if ( $count > 0 ) { |
95
|
|
|
|
|
|
|
$self->tail($engine)->done( |
96
|
|
|
|
|
|
|
sub { |
97
|
0
|
|
|
0
|
|
|
my ($tail) = @_; |
98
|
0
|
|
|
|
|
|
$tail->_walk_tail( $engine, $d, $count - 1 ); |
99
|
|
|
|
|
|
|
}, |
100
|
|
|
|
|
|
|
sub { |
101
|
0
|
|
|
0
|
|
|
$d->reject(@_); |
102
|
|
|
|
|
|
|
} |
103
|
0
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
else { |
106
|
|
|
|
|
|
|
$self->head($engine)->done( |
107
|
|
|
|
|
|
|
sub { |
108
|
0
|
|
|
0
|
|
|
$d -> resolve(@_); |
109
|
|
|
|
|
|
|
}, |
110
|
|
|
|
|
|
|
sub { |
111
|
0
|
|
|
0
|
|
|
$d -> reject(@_); |
112
|
|
|
|
|
|
|
} |
113
|
0
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub apply_map { |
118
|
0
|
|
|
0
|
0
|
|
my ( $self, $engine, $transform ) = @_; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
return $engine->make_map($transform)->then( |
121
|
|
|
|
|
|
|
sub { |
122
|
0
|
|
|
0
|
|
|
my ($map_t) = @_; |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
return $map_t->apply( $engine, {}, $self ); |
125
|
|
|
|
|
|
|
} |
126
|
0
|
|
|
|
|
|
); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub apply_filter { |
130
|
0
|
|
|
0
|
0
|
|
my ( $self, $engine, $filter ) = @_; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
return $engine->make_filter($filter)->then( |
133
|
|
|
|
|
|
|
sub { |
134
|
0
|
|
|
0
|
|
|
my ($filter_t) = @_; |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
return $filter_t->apply( $engine, {}, $self ); |
137
|
|
|
|
|
|
|
} |
138
|
0
|
|
|
|
|
|
); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; |