Curry - a Raku module for currying functions.
NAME
Curry - a Raku module for currying functions.
SYNOPSIS
use Curry:auth<zef:CIAvash> :all;
# Curried subs
sub f ($a, $b) is curry {
$a Ć $b;
}
my &pf = f 2;
say pf 3;
=output 6ā¤
sub f2 ($a, $b, :$c = 1) is curry {
[Ć] $a, $b, $c;
}
my &pf2 = f 2, :c(4);
say pf 3;
=output 24ā¤
sub f3 (*@a) is curry {
[Ć] @a;
}
my &pf3 = f 2, 3;
say pf;
=output 6ā¤
say pf(4)();
=output 24ā¤
# Curried method and attribute
my class C {
has &.f is curry is rw;
method m (Int $a, Int $b) is curry {
$a Ć $b;
}
}
my C $c .= new;
# Method
say $c.m(2, 3)()
=output 6ā¤
my &pm = $c.m(2, 3);
say pm;
=output 6ā¤
say pm(4)();
=output 24ā¤
# Attribute
$c.f = * + *;
say $c.f.(1, 2);
=output 3ā¤
my &pa = $c.f.(1);
say pa 2;
=output 3ā¤
# Making Curry
my &f3 = Curry[* + *];
# Or
my &f4 = make_curry * + *;
my &cgrep = Curry[&grep];
# Or better
my &cgrep2 = new_curry &grep;
# Be careful with this
make_curry &grep;
# Or
make_curryable &grep; # This changes function's signature
# Original function (before being curried)
my &lost_grep = &grep.original_function;
INSTALLATION
You need to have Raku and zef, then run:
zef install --/test Curry:auth<zef:CIAvash>
or if you have cloned the repo:
zef install .
TESTING
prove -ve 'raku -I.' --ext rakutest
ROLES
SUBS
REPOSITORY
AUTHOR
Siavash Askari Nasr - https://www.ciavash.name
COPYRIGHT
Copyright Ā© 2021 Siavash Askari Nasr
LICENSE
This file is part of Curry.
Curry is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at yoption) any later version.
Curry is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with Curry. If not, see <http://www.gnu.org/licenses/>.