line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dallycot::AST::Reciprocal; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:JSMITH'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# ABSTRACT: Calculates the reciprocal of a numeric value |
5
|
|
|
|
|
|
|
|
6
|
23
|
|
|
23
|
|
12421
|
use strict; |
|
23
|
|
|
|
|
41
|
|
|
23
|
|
|
|
|
694
|
|
7
|
23
|
|
|
23
|
|
89
|
use warnings; |
|
23
|
|
|
|
|
29
|
|
|
23
|
|
|
|
|
446
|
|
8
|
|
|
|
|
|
|
|
9
|
23
|
|
|
23
|
|
80
|
use utf8; |
|
23
|
|
|
|
|
30
|
|
|
23
|
|
|
|
|
102
|
|
10
|
23
|
|
|
23
|
|
389
|
use parent 'Dallycot::AST'; |
|
23
|
|
|
|
|
37
|
|
|
23
|
|
|
|
|
155
|
|
11
|
|
|
|
|
|
|
|
12
|
23
|
|
|
23
|
|
995
|
use Readonly; |
|
23
|
|
|
|
|
40
|
|
|
23
|
|
|
|
|
5011
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Readonly my $NUMERIC => ['Numeric']; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub to_string { |
17
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
return "1/(" . $self->[0]->to_string . ")"; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub to_rdf { |
23
|
0
|
|
|
0
|
0
|
|
my($self, $model) = @_; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
return $model -> apply( |
26
|
|
|
|
|
|
|
$model -> meta_uri('loc:reciprocal'), |
27
|
|
|
|
|
|
|
[ $self->[0] ], |
28
|
|
|
|
|
|
|
{} |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
# my $bnode = $model -> bnode; |
31
|
|
|
|
|
|
|
# $model -> add_type($bnode, 'loc:Reciprocal'); |
32
|
|
|
|
|
|
|
# $model -> add_expression($self -> [0]); |
33
|
|
|
|
|
|
|
# return $bnode; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub execute { |
37
|
0
|
|
|
0
|
0
|
|
my ( $self, $engine ) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return $engine->execute( $self->[0], $NUMERIC )->then( |
40
|
|
|
|
|
|
|
sub { |
41
|
0
|
|
|
0
|
|
|
Dallycot::Value::Numeric->new( 1 / ( $_[0]->value ) ); |
42
|
|
|
|
|
|
|
} |
43
|
0
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |