blib/lib/List/Gen/Lazy/Ops.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran n/a Conditioncond 0.0% 0 / 4 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 30 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package List::Gen::Lazy::Ops;
2 use strict;
3 use warnings;
4 use lib '../../';
5 use List::Gen::Lazy 'fn';
6
7 =head1 NAME
8
9 List::Gen::Lazy::Ops - perl ops with partial + lazy application
10
11 =head1 SYNOPSIS
12
13 this module implements some of the perl operators with C< fn() > from
14 L<List::Gen::Lazy>
15
16 the implemented infix operators are:
17
18 + - / * % . & | ^ < >
19
20 the implemented prefix operators are:
21
22 ! ~
23
24 each is a subroutine and must be prefixed by C< & >:
25
26 my $plus_1 = &+(1);
27
28 say 5->$plus_1; # 6
29
30 this module mainly exists to ease writing expressions like:
31
32 use List::Gen::Haskell;
33
34 my $sum = foldl \&+;
35
36 $_ = L 0, 1, zipWith \&+, $_, tail $_ for my $fibs;
37
38 =head1 AUTHOR
39
40 Eric Strom, C<< <asg at cpan.org> >>
41
42 =head1 BUGS
43
44 report any bugs / feature requests to C<bug-list-gen at rt.cpan.org>, or through
45 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=List-Gen>.
46
47 comments / feedback / patches are also welcome.
48
49 =head1 COPYRIGHT & LICENSE
50
51 copyright 2009-2011 Eric Strom.
52
53 this program is free software; you can redistribute it and/or modify it under
54 the terms of either: the GNU General Public License as published by the Free
55 Software Foundation; or the Artistic License.
56
57 see http://dev.perl.org/licenses/ for more information.
58
59 =cut
60
61
62 no strict 'refs';
63
64 *$_ = eval "fn {\$_[0] $_ \$_[1]} 2" || die $@ for qw (+ - / * % . & | ^ < >);
65 *$_ = eval "fn {$_ \$_[0]} 1" || die $@ for qw (! ~);
66
67 *: = fn {unshift @{$_[1]}, $_[0]; $_[1]} 2;
68
69 1;