| 1 | package Math::Symbolic::Custom::Contains; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Carp qw/croak carp cluck confess/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use Math::Symbolic::Custom::Base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | BEGIN { *import = \&Math::Symbolic::Custom::Base::aggregate_import } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | use Math::Symbolic::ExportConstants qw/:all/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | our $VERSION = '1.01'; | |||||||||
| 13 | |||||||||||
| 14 | 1 | our $Aggregate_Export = [qw/contains_operator/]; | |||||||||
| 15 | |||||||||||
| 16 | 6 | ▶ | sub contains_operator { | ||||||||
|
Subroutine
contains_operator: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||
| 17 | 6 | my ( $f, $op ) = @_; | |||||||||
| 18 | |||||||||||
| 19 | 6 | my @nodes = ($f); | |||||||||
| 20 | 6 | ▶ | while (@nodes) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 12 | my $n = shift @nodes; | |||||||||
| 22 | 12 | ▶ | if ( ref $n eq 'Math::Symbolic::Operator' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 8 | ▶ | if ( not defined $op ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 1 | return $n; | |||||||||
| 25 | } | ||||||||||
| 26 | else { | ||||||||||
| 27 | 7 | ▶ | if ( $n->type() == $op ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 3 | return $n; | |||||||||
| 29 | } | ||||||||||
| 30 | else { | ||||||||||
| 31 | 4 | my @ops = $n->descending_operands(); | |||||||||
| 32 | 4 | push @nodes, @ops; | |||||||||
| 33 | } | ||||||||||
| 34 | } | ||||||||||
| 35 | } | ||||||||||
| 36 | else { | ||||||||||
| 37 | 4 | next; | |||||||||
| 38 | } | ||||||||||
| 39 | } | ||||||||||
| 40 | 2 | return (undef); | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 1 | 1; | |||||||||
| 44 | __END__ | ||||||||||