Created
January 13, 2023 01:56
-
-
Save tony-o/9d4fe1e20d88033649d69ab568b7ca61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub trait_mod:<is> (Sub:D $s, :$partial) { | |
$s.wrap(sub (*%_) { | |
if %_.elems == $s.signature.params.elems { | |
callwith |%_; | |
} else { | |
my %cache = %_; | |
return sub (*%_) { | |
$s.(|%_, |%cache); | |
}; | |
}; | |
}); | |
}; | |
sub x (:$name, :$title) is partial { | |
"{$title}. {$name}".say; | |
}; | |
x(:name<tony>, :title<m>); | |
my $partial = x(:name<tony>); | |
$partial.(:title<m2>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment