Permalink
Browse files

Remove dead code in hand-cached version, update testing harness to be…

… more careful.
  • Loading branch information...
1 parent e816e6a commit 84c1bf977ee54134fea0c2450ca57d89b7a80b08 @colomon committed Dec 21, 2012
Showing with 6 additions and 15 deletions.
  1. +0 −14 bin/collatz-recursive-ternary-hand-cached.pl
  2. +6 −1 bin/testing-harness.pl
@@ -1,17 +1,3 @@
-multi sub trait_mod:<is>(Routine $r, :$cached!) {
- my %cache;
- #wrap the routine in a block that..
- $r.wrap(-> $arg {
- # looks up the argument in the cache
- %cache.exists($arg)
- ?? %cache{$arg}
- # ... and calls the original, if it
- # is not found in the cache
- !! (%cache{$arg} = callwith($arg))
- }
- );
-}
-
sub collatz-length(Int $n) {
return 1 if $n == 1;
state %lengths;
View
@@ -11,8 +11,13 @@
sub MAIN(Str $perl6, *@scripts) {
for @scripts -> $script {
my $results = qqx/$perl6 $script { @numbers }/;
+ my @results = $results.lines.map({ $_.comb(/\d+/) }).map(* => *);
+
+ say "Hey, $script doesn't seem to have done the assigned work"
+ unless @numbers (<=) @results && @results (<=) @numbers;
+
my @mistakes;
- for $results.lines.map({ $_.comb(/\d+/) }) -> $n, $length {
+ for @results -> (:key($n), :value($length)) {
push @mistakes, $n if collatz-length($n.Int) != $length;
}
if @mistakes {

0 comments on commit 84c1bf9

Please sign in to comment.