[ruby-dev:47225] [ruby-trunk - Feature #7877] E::Lazy#with_index needed

From: "zzak (Zachary Scott)" <zachary@...>
Date: 2013-04-05 02:32:41 UTC
List: ruby-dev #47225
Issue #7877 has been updated by zzak (Zachary Scott).


Propose to move this to next major?
----------------------------------------
Feature #7877: E::Lazy#with_index needed
https://bugs.ruby-lang.org/issues/7877#change-38245

Author: shyouhei (Shyouhei Urabe)
Status: Assigned
Priority: Normal
Assignee: yhara (Yutaka HARA)
Category: core
Target version: next minor


=begin
So I wanted some real benefit of being lazy.  I wrote a Leibniz formula:

  def leibniz(n)
    (0..Float::INFINITY).lazy.with_index {|i, j| (-1 ** j) / (2*i+1).to_f }.take(n).reduce(:+)
  end

But it doesn't work (well, it does, indeed. It just doesn't stop working).  I got frustrated.
How about it?  Don't you feel it nifty?

Of course I can wait for the release next to 2.0.0.
=end


-- 
http://bugs.ruby-lang.org/

In This Thread

Prev Next