Skip to content

Fix Ruby find_min implementation#49

Merged
kou merged 1 commit intored-data-tools:masterfrom
kojix2:patch-1
Mar 15, 2026
Merged

Fix Ruby find_min implementation#49
kou merged 1 commit intored-data-tools:masterfrom
kojix2:patch-1

Conversation

@kojix2
Copy link
Copy Markdown
Member

@kojix2 kojix2 commented Mar 15, 2026

Fix the pure Ruby implementation of find_min.
Since this method is overridden by a method in the C extension, there is no actual harm.

require_relative "lib/enumerable_statistics/array_ext.rb"
p [3, 1, 2].find_min

Before

/home/kojix2/Ruby/enumerable-statistics/lib/enumerable_statistics/array_ext.rb:25:in 'EnumerableStatistics::ArrayExtension#find_min': undefined local variable or method 'imax' for an instance of Array (NameError)

        imin = i if self[i] < self[imax]
                                   ^^^^
Did you mean?  max
        from (irb):2:in '<main>'
        from /home/kojix2/.local/share/mise/installs/ruby/4.0.1/lib/ruby/gems/4.0.0/gems/irb-1.17.0/exe/irb:9:in '<top (required)>'
        from /home/kojix2/.local/share/mise/installs/ruby/4.0.1/lib/ruby/4.0.0/rubygems.rb:303:in 'Kernel#load'
        from /home/kojix2/.local/share/mise/installs/ruby/4.0.1/lib/ruby/4.0.0/rubygems.rb:303:in 'Gem.activate_and_load_bin_path'
        from /home/kojix2/.local/share/mise/installs/ruby/4.0.1/bin/irb:25:in '<main>'

After

=> [1, 1]


imax, i = 0, 1
while i < n
imax = i if self[i] > self[imax]
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This typo likely came from here

@kou kou merged commit 45f4fed into red-data-tools:master Mar 15, 2026
30 checks passed
@kou
Copy link
Copy Markdown
Member

kou commented Mar 15, 2026

Good catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants