| 1 | package Logic::Relational::Goal::Any; | ||||||||||
| 2 | |||||||||||
| 3 | 31 | ▶ | use v5.38; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 31 | ▶ | use experimental 'signatures'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 31 | ▶ | use parent 'Logic::Relational::Goal'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | =head1 NAME | ||||||||||
| 8 | |||||||||||
| 9 | Logic::Relational::Goal::Any - Disjunction of goals (OR). | ||||||||||
| 10 | |||||||||||
| 11 | =cut | ||||||||||
| 12 | |||||||||||
| 13 | 5 | ▶ | sub new ( $class, $goals ) { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 14 | 5 | return bless { goals => $goals }, $class; | |||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | 0 | ▶ | sub goals ($self) { return $self->{goals}; } | ||||||||
|
Subroutine
goals: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 18 | |||||||||||
| 19 | 3 | ▶ | sub expand ( $self, %args ) { | ||||||||
|
Subroutine
expand: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 20 | 3 | my $state = $args{state}; | |||||||||
| 21 | 3 | my $remaining = $args{remaining}; | |||||||||
| 22 | 3 | my @successors; | |||||||||
| 23 | 3 | for my $goal ( @{ $self->{goals} } ) { | |||||||||
| 24 | 7 | my $succ = $state->derive( goals => [ $goal, @$remaining ], ); | |||||||||
| 25 | 7 | ▶ | push @successors, $succ if $succ; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | } | ||||||||||
| 27 | 3 | return @successors; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 2 | ▶ | sub freshen ( $self, $var_map ) { | ||||||||
|
Subroutine
freshen: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 31 | 2 | my @fresh_goals = map { $_->freshen($var_map) } @{ $self->{goals} }; | |||||||||
| 32 | 2 | return ref($self)->new( \@fresh_goals ); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 0 | ▶ | sub is_ground ( $self, $subst ) { | ||||||||
|
Subroutine
is_ground: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 36 | 0 | for my $goal ( @{ $self->{goals} } ) { | |||||||||
| 37 | 0 | ▶ | return 0 unless $goal->is_ground($subst); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | } | ||||||||||
| 39 | 0 | return 1; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 31 | 1; | |||||||||