-
-
Save zoffixznet/4a623b529d2f52e833e3 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
unit module Class::Descendants:ver<1.001001>; | |
sub descendants ($name) is export { | |
return @( | |
|fetch-descendants($name, ::GLOBAL.WHO), | |
|fetch-descendants($name, ::CORE.WHO), | |
) | |
} | |
sub fetch-descendants ($name, $ns, $prefix = '') { | |
my @descendants; | |
for $ns.keys { | |
my $key = $prefix ~ $_; | |
try my @parents = ::($key).^parents: :all; | |
@descendants.push: $key if $key ⊆ @parents; | |
say "$key [$_]"; say $ns{$_}.WHAT; | |
next unless $ns{$_}.WHAT; | |
@descendants.append: fetch-descendants $name, $ns{$_}, $key ~ '::' | |
if $ns{$_}.keys; | |
} | |
return @descendants.unique; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment