GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  DATA::UTIL::CURRY (3)

.ds Aq ’

NAME

Data::Util::Curry - Curries functions and methods

CONTENTS

SYNOPSIS



        use feature say;
        use Data::Util qw(curry);

        sub sum{
                my $total = 0;
                for my $x(@_){
                        $total += $x;
                }
                return $total;
        }

        # placeholder "\0" indicates a subscript of the arguments
        say curry(\&add, \0, 42)->(10); # 52

        # placeholder "*_" indicates all the arguments
        say curry(\&add, *_)->(1 .. 10); # 55

        # two subscripts and the rest of the arguments
        say curry(\&add, *_, \1, \0)->(1 .. 5); # 3 + 4 + 5 + 1 + 2



DESCRIPTION

(todo)

EXAMPLES

    Currying Functions



        curry(\&f, \0, 2)->(1); # f(1, 2)
        curry(\&f, 3, \0)->(4); # f(3, 4)
        curry(\&f, *_)->(5, 6); # f(5, 6)

        curry(\&f, \0, \1, *_)->(1, 2, 3, 4); # f(1, 2, 3, 4)
        curry(\&f, *_, \0, \1)->(1, 2, 3, 4); # f(3, 4, 1, 2)



    Currying Methods



        curry($obj, something, *_)->(1, 2);  # $obj->something(1, 2)

        curry($obj, something,
                foo => \0,
                bar => \1)->(1, 2); # $obj->something(foo => 1, bar => 2)

        curry(\0, something, \1)->($obj, 42);   # $obj->something(42)
        curry($obj, \0, *_)->(something, 1, 2); # $obj->something(1, 2)



    Argument Semantics



        sub incr{ $_[0]++ }

        my $i = 0;
        curry(\&incr, \0)->($i); # $i++
        curry(\&incr, *_)->($i); # $i++
        curry(\&incr, $i)->();   # $i++



SEE ALSO

Data::Util.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 DATA::UTIL::CURRY (3) 2012-10-20

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.