chiark / gitweb /
quacks-ingredients: wip Base vs Witches vs Both
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 28 Mar 2020 21:36:01 +0000 (21:36 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 28 Mar 2020 21:36:01 +0000 (21:36 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
quacks-ingredients-counts
quacks-ingredients-update-levels

index 3e49a9528c227f2b1a8c48ae3cced84429741a78..15e6bd8c52ad5325d053964c85a90375de365c02 100755 (executable)
@@ -5,8 +5,11 @@ use strict;
 use Data::Dumper;
 use POSIX;
 
+our $which = shift @ARGV;
+
 sub xdata ($) {
     my ($cb) = @_;
+    return unless $which eq 'Base';
     foreach my $count (qw(1 2 3)) {
        foreach my $nspots (qw(1 2 3 4)) {
            $_ = $cb->($count,$nspots)."\t".$_;
@@ -27,14 +30,25 @@ foreach my $nspots (qw(1 2 3 4)) {
     $_=<DATA>; chomp or die;
     xdata sub {
        my ($xcount,$xnspots) = @_;
-       $xnspots == $nspots and $xcount;
+       $xnspots == $nspots and "$xcount+0";
     };
     my @l = split /\t/, $_;
-    foreach my $i (0..$#names) { $count{$names[$i]}{$nspots} = $l[$i] || 0; }
+    foreach my $i (0..$#names) {
+       $_ = $l[$i] || '0+0';
+       $_ ||= 0;
+       m/\+/;
+       
+       $count{$names[$i]}{$nspots} =
+           $which eq 'Both'    ? $` + $' :
+           $which eq 'Base'    ? $`      :
+           $which eq 'Witches' ?      $' :
+           die "$which ?";
+    }
 }
 
 $_ = Dumper(\%count);
 s{^}{// }mg;
+#print STDERR;
 
 our $name;
 our $total_count;
@@ -89,7 +103,7 @@ STDOUT->error and die $!;
 
 __DATA__
 White  Green   Blue    Red     Yellow  Purple  Black   Orange
-20     15      14      12      13      15      18      20
-8      10      10      8       6
-4
-       13      10      10      10
+20+6   15+10   14+8    12+6    13+6    15+8    18+8    20+12
+8+3    10+5    10+5    8+5     6+5
+4+2
+       13+5    10+5    10+5    10+5
index f0dbd4bfe4f1653a116c498309ef3d862d555008..ed81826e781139bbe4b212c3fadaa9a54a8d3ce8 100755 (executable)
@@ -20,7 +20,7 @@ cat >$f.tmp <<END
 //   source is quacks-ingredients-counts
 END
 
-./quacks-ingredients-counts >>$f.tmp
+./quacks-ingredients-counts Base >>$f.tmp
 mv -f $f.tmp $f
 
 egrep '^// [A-Za-z]' $f | sort