| 1 | package Logic::Relational::ArrayRest; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 12 | ▶ | use v5.38; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use experimental 'signatures'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 12 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | Logic::Relational::ArrayRest - Represents a rest/slurp wrapper for array unification. | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | use Logic::Relational::ArrayRest; | ||||||||||||||||||||||||||||
| 14 | my $rest = Logic::Relational::ArrayRest->new($variable); | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | C<Logic::Relational::ArrayRest> wraps a term to represent the rest of an array | ||||||||||||||||||||||||||||
| 19 | in unification. It is constructed using the C<rest> or C<slurp> DSL helpers. | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =head1 METHODS | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =head2 new | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | Constructor. Takes a single term (usually a variable). | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | =head2 term | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | Returns the wrapped term. | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =head2 as_string | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | Returns the string representation of the wrapper. | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =head2 freshen | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | Freshens the inner term, returning a new C<Logic::Relational::ArrayRest> object. | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =cut | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 375 | ▶ | sub new ( $class, $term ) { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 42 | 375 | return bless { term => $term }, $class; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 334 | ▶ | sub term ($self) { | ||||||||||||||||||||||||||
|
Subroutine
term: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 46 | 334 | return $self->{term}; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 12 | ▶ | use builtin 'blessed'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 50 | 12 | ▶ | no warnings 'experimental::builtin'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub as_string ($self) { | ||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 53 | 0 | my $term = $self->{term}; | |||||||||||||||||||||||||||
| 54 | 0 | ▶ | my $term_str = | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($term) and $term->can("as_string")
MC/DC0%0/2
builtin::blessed($term) and $term->can("as_string")
builtin::blessed($term)
$term->can("as_string")
Truth table0%0/3
A and B
A= builtin::blessed($term)B= $term->can("as_string")
| |||||||||||||||||||||||||||||
| 55 | blessed($term) && $term->can('as_string') ? $term->as_string : "$term"; | ||||||||||||||||||||||||||||
| 56 | 0 | return "rest($term_str)"; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub freshen ( $self, $var_map ) { | ||||||||||||||||||||||||||
|
Subroutine
freshen: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 60 | 0 | my $term = $self->{term}; | |||||||||||||||||||||||||||
| 61 | 0 | ▶ | my $fresh_term = | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($term) and $term->can("freshen")
MC/DC0%0/2
builtin::blessed($term) and $term->can("freshen")
builtin::blessed($term)
$term->can("freshen")
Truth table0%0/3
A and B
A= builtin::blessed($term)B= $term->can("freshen")
| |||||||||||||||||||||||||||||
| 62 | blessed($term) && $term->can('freshen') ? $term->freshen($var_map) : $term; | ||||||||||||||||||||||||||||
| 63 | 0 | return ref($self)->new($fresh_term); | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 12 | 1; | |||||||||||||||||||||||||||