Project

General

Profile

Actions

Bug #7877

closed

E::Lazy#with_index should be lazy

Added by shyouhei (Shyouhei Urabe) almost 12 years ago. Updated about 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
2.1.0-dev
[ruby-dev:47025]

Description

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.


Files

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0