Skip to content

Instantly share code, notes, and snippets.

@gfldex
Created September 30, 2020 18:39
Show Gist options
  • Save gfldex/b94039d4bd57a063c6b3e94a23683ef1 to your computer and use it in GitHub Desktop.
Save gfldex/b94039d4bd57a063c6b3e94a23683ef1 to your computer and use it in GitHub Desktop.
use v6;
proto s(|c) {
my $capture-types := c.list.map({.WHAT}).cache;
for &?ROUTINE.candidates -> &c {
my @candidate-types := &c.signature.params».type;
if @candidate-types (==) $capture-types {
my @right-order;
for @candidate-types -> \type {
@right-order.push: c.grep({type === $_.WHAT})[0];
}
return &c(|@right-order);
}
}
}
multi s(Int $i, Str $s) {
say [$i, $s];
}
s('answer', 42);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment