From: Ian Jackson Date: Mon, 1 Aug 2016 16:09:52 +0000 (+0100) Subject: stv: fix historically_prefer X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=appendix-a6.git;a=commitdiff_plain;h=be8af598391869fa6bb4cf9ccf630a09f6c2edd8;hp=0f260f3d622f00becab215877dba0e2e260603c5 stv: fix historically_prefer --- diff --git a/stv b/stv index dae5563..3942b6b 100755 --- a/stv +++ b/stv @@ -106,13 +106,14 @@ sub historically_prefer ($@) { return 0; }; - @choices = sort $compare, @choices; + @choices = sort $compare @choices; $a = $choices[0]; - my $numequal = 0; + my $numequal = 1; for (;;) { - last unless $numequal >= @choices; + last if $numequal >= @choices; $b = $choices[$numequal]; last if $compare->(); + $numequal++; } die 'random choice unimplemented' if $numequal > 1;