Project

General

Profile

Actions

Bug #3581

closed

Array#combination enumerator ends iteration early

Added by Phrogz (Gavin Kistner) almost 12 years ago. Updated about 11 years ago.

Status:
Rejected
Priority:
Normal
ruby -v:
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
[ruby-core:31318]

Description

=begin
C:>type big_combination.rb
count = 0
combo = nil
(1..166).to_a.combination(5).each do |c|
count+= 1; combo = c
end
p count, combo

C:>ruby -v big_combination.rb
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
129462338
[5, 34, 54, 73, 81]

The same (incorrect) results are witnessed using 1.9.1p378 on Ubuntu.

The expected result should be:
988455798
[162, 163, 164, 165, 166]

As noted in a ruby-talk thread[1], the correct results were seen on 1.9.1p129

Note that changing "166" to "141" in the above code instead results in the RangeError "in `combination': too big for combination". Perhaps this is the same issue as bug #3089 [ruby-core:29240].

[1] http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/c558332ff0a053ad/67e87e76d289889e#67e87e76d289889e
=end


Files

big_combination.rb (115 Bytes) big_combination.rb Phrogz (Gavin Kistner), 07/17/2010 04:52 AM
Actions #1

Updated by marcandre (Marc-Andre Lafortune) almost 12 years ago

  • Category set to core
  • Status changed from Open to Rejected
  • Assignee set to marcandre (Marc-Andre Lafortune)

=begin
This is already been fixed. Please update your Ruby to either the 1.9.2 rc2 or trunk.
=end

Actions

Also available in: Atom PDF