Skip to content

Instantly share code, notes, and snippets.

@samcv
Created May 4, 2017 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samcv/5744ddcbb51cabd9e1f56bf6591a6d7b to your computer and use it in GitHub Desktop.
Save samcv/5744ddcbb51cabd9e1f56bf6591a6d7b to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl6
use lib <lib>;
use Universe;
#my %physics = LawCmd.create(@*ARGS.Str);
#my %physics-cnf = LawCnf.create('bin/laws');
#say %physics.perl;
#say $u.physics.perl;
use nqp;
#my %physics = LawCmd.create(@*ARGS.Str);
#my %physics-cnf = LawCnf.create('bin/laws');
#say %physics.perl;
my $u = Universe.new;
my %hash = $u.physics;
print-keys %hash;
sub print-keys (%hash, Int:D $indent = 0) {
say "\nLevel $indent elems: ", %hash.keys.elems;
for %hash.keys {
my $thing = %hash{$_};
if !nqp::defined($thing) {
print ' ' x $indent;
say "$_ => ", try { $thing.WHAT } // try { nqp::what($thing) } // 'NQPMu';
}
else {
print ' ' x $indent ~ "$_ => ";
if $thing ~~ Hash {
print-keys $thing, $indent + 1;
}
else {
say try { %hash{$_}.WHICH }
}
}
}
}
say $u.galaxy.laws.perl;
say $u.alien.laws.perl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment