Created
May 4, 2017 22:59
-
-
Save samcv/5744ddcbb51cabd9e1f56bf6591a6d7b 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
#!/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