| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Quantum::Superpositions::Lazy; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '1.11'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
15
|
|
|
15
|
|
598486
|
use v5.24; |
|
|
15
|
|
|
|
|
143
|
|
|
6
|
15
|
|
|
15
|
|
120
|
use warnings; |
|
|
15
|
|
|
|
|
68
|
|
|
|
15
|
|
|
|
|
507
|
|
|
7
|
15
|
|
|
15
|
|
92
|
use Carp qw(croak); |
|
|
15
|
|
|
|
|
32
|
|
|
|
15
|
|
|
|
|
653
|
|
|
8
|
15
|
|
|
15
|
|
6163
|
use Quantum::Superpositions::Lazy::Superposition; |
|
|
15
|
|
|
|
|
51
|
|
|
|
15
|
|
|
|
|
509
|
|
|
9
|
15
|
|
|
15
|
|
98
|
use Quantum::Superpositions::Lazy::Operation::Logical; |
|
|
15
|
|
|
|
|
31
|
|
|
|
15
|
|
|
|
|
337
|
|
|
10
|
15
|
|
|
15
|
|
68
|
use Quantum::Superpositions::Lazy::Util qw(is_collapsible); |
|
|
15
|
|
|
|
|
41
|
|
|
|
15
|
|
|
|
|
669
|
|
|
11
|
15
|
|
|
15
|
|
78
|
use Exporter qw(import); |
|
|
15
|
|
|
|
|
31
|
|
|
|
15
|
|
|
|
|
7749
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
14
|
|
|
|
|
|
|
superpos |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
|
18
|
|
|
|
|
|
|
collapse |
|
19
|
|
|
|
|
|
|
any_state |
|
20
|
|
|
|
|
|
|
every_state |
|
21
|
|
|
|
|
|
|
one_state |
|
22
|
|
|
|
|
|
|
fetch_matches |
|
23
|
|
|
|
|
|
|
with_sources |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
27
|
|
|
|
|
|
|
all => [@EXPORT, @EXPORT_OK], |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $global_reducer_type = "any"; |
|
31
|
|
|
|
|
|
|
our $global_compare_bool = 1; |
|
32
|
|
|
|
|
|
|
our $global_sourced_calculations = 0; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub run_sub_as |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
46
|
|
|
46
|
0
|
141
|
my ($sub, %env) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
46
|
|
66
|
|
|
186
|
local $global_reducer_type = $env{reducer_type} // $global_reducer_type; |
|
39
|
46
|
|
100
|
|
|
179
|
local $global_compare_bool = $env{compare_bool} // $global_compare_bool; |
|
40
|
46
|
|
66
|
|
|
144
|
local $global_sourced_calculations = $env{sourced_calculations} // $global_sourced_calculations; |
|
41
|
46
|
|
|
|
|
97
|
return $sub->(); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub superpos |
|
45
|
|
|
|
|
|
|
{ |
|
46
|
71
|
|
|
71
|
1
|
29061
|
my (@positions) = @_; |
|
47
|
71
|
|
|
|
|
127
|
my $positions_ref; |
|
48
|
|
|
|
|
|
|
|
|
49
|
71
|
50
|
66
|
|
|
286
|
if (@positions == 1 && ref $positions[0] eq ref []) { |
|
50
|
0
|
|
|
|
|
0
|
$positions_ref = $positions[0]; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
else { |
|
53
|
71
|
|
|
|
|
973
|
$positions_ref = [@positions]; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
71
|
|
|
|
|
1553
|
return Quantum::Superpositions::Lazy::Superposition->new( |
|
57
|
|
|
|
|
|
|
states => $positions_ref |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub collapse |
|
62
|
|
|
|
|
|
|
{ |
|
63
|
1
|
|
|
1
|
1
|
72
|
my (@superpositions) = @_; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
return map { |
|
66
|
1
|
50
|
|
|
|
3
|
croak "Element not collapsible" |
|
|
3
|
|
|
|
|
44
|
|
|
67
|
|
|
|
|
|
|
unless is_collapsible($_); |
|
68
|
3
|
|
|
|
|
58
|
$_->collapse; |
|
69
|
|
|
|
|
|
|
} @superpositions; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub any_state(&) |
|
73
|
|
|
|
|
|
|
{ |
|
74
|
4
|
|
|
4
|
1
|
9
|
my ($sub) = @_; |
|
75
|
|
|
|
|
|
|
|
|
76
|
4
|
|
|
|
|
11
|
return run_sub_as $sub, reducer_type => "any"; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub every_state(&) |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
14
|
|
|
14
|
1
|
230
|
my ($sub) = @_; |
|
82
|
|
|
|
|
|
|
|
|
83
|
14
|
|
|
|
|
51
|
return run_sub_as $sub, reducer_type => "all"; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub one_state(&) |
|
87
|
|
|
|
|
|
|
{ |
|
88
|
9
|
|
|
9
|
1
|
105
|
my ($sub) = @_; |
|
89
|
|
|
|
|
|
|
|
|
90
|
9
|
|
|
|
|
21
|
return run_sub_as $sub, reducer_type => "one"; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub fetch_matches(&) |
|
94
|
|
|
|
|
|
|
{ |
|
95
|
13
|
|
|
13
|
1
|
23278
|
my ($sub) = @_; |
|
96
|
|
|
|
|
|
|
|
|
97
|
13
|
|
|
|
|
55
|
return run_sub_as $sub, compare_bool => 0; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub with_sources(&) |
|
101
|
|
|
|
|
|
|
{ |
|
102
|
6
|
|
|
6
|
1
|
9810
|
my ($sub) = @_; |
|
103
|
|
|
|
|
|
|
|
|
104
|
6
|
|
|
|
|
25
|
return run_sub_as $sub, sourced_calculations => 1; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |
|
108
|
|
|
|
|
|
|
__END__ |