Permalink
Browse files

Fixed last-block rounding error

  • Loading branch information...
1 parent e08dc04 commit 1a3ad310d520aa901544cae39e24ee2c53721c77 @spencertipping committed Nov 6, 2010
Showing with 10 additions and 8 deletions.
  1. +5 −4 fcm/order1
  2. +5 −4 fcm/order1.sdoc
View
9 fcm/order1
@@ -34,12 +34,13 @@ sub write_file {
close $fh;
}
+my $block_number = 0;
my $write_batch = sub {
- my $file_number = int($i / $block_size);
- print STDERR "Writing block $file_number\n";
+ ++$block_number;
+ print STDERR "Writing block $block_number\n";
- write_file "blocks/before-$file_number", sub {&{$_[0]}("$_ " . join(' ', %{$second_words_for{$_}}), "\n") for sort keys %second_words_for};
- write_file "blocks/after-$file_number", sub {&{$_[0]}("$_ " . join(' ', %{$first_words_for{$_}}), "\n") for sort keys %first_words_for};
+ write_file "blocks/before-$block_number", sub {&{$_[0]}("$_ " . join(' ', %{$second_words_for{$_}}), "\n") for sort keys %second_words_for};
+ write_file "blocks/after-$block_number", sub {&{$_[0]}("$_ " . join(' ', %{$first_words_for{$_}}), "\n") for sort keys %first_words_for};
%second_words_for = %first_words_for = ();
};
View
9 fcm/order1.sdoc
@@ -34,12 +34,13 @@ sub write_file {
close $fh;
}
+my $block_number = 0;
my $write_batch = sub {
- my $file_number = int($i / $block_size);
- print STDERR "Writing block $file_number\n";
+ ++$block_number;
+ print STDERR "Writing block $block_number\n";
- write_file "blocks/before-$file_number", sub {&{$_[0]}("$_ " . join(' ', %{$second_words_for{$_}}), "\n") for sort keys %second_words_for};
- write_file "blocks/after-$file_number", sub {&{$_[0]}("$_ " . join(' ', %{$first_words_for{$_}}), "\n") for sort keys %first_words_for};
+ write_file "blocks/before-$block_number", sub {&{$_[0]}("$_ " . join(' ', %{$second_words_for{$_}}), "\n") for sort keys %second_words_for};
+ write_file "blocks/after-$block_number", sub {&{$_[0]}("$_ " . join(' ', %{$first_words_for{$_}}), "\n") for sort keys %first_words_for};
%second_words_for = %first_words_for = ();
};

0 comments on commit 1a3ad31

Please sign in to comment.