File: C:/Ruby27-x64/share/ri/2.7.0/system/Enumerable/lazy-i.ri
U:RDoc::AnyMethod[iI" lazy:ETI"Enumerable#lazy;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"BReturns an Enumerator::Lazy, which redefines most Enumerable ;TI"Emethods to postpone enumeration and enumerate values only on an ;TI"as-needed basis.;To:RDoc::Markup::BlankLine S:RDoc::Markup::Heading:
leveli: textI"Example;T@o;
; [I"5The following program finds pythagorean triples:;T@o:RDoc::Markup::Verbatim; [I"def pythagorean_triples
;TI"/ (1..Float::INFINITY).lazy.flat_map {|z|
;TI" (1..z).flat_map {|x|
;TI" (x..z).select {|y|
;TI"! x**2 + y**2 == z**2
;TI" }.map {|y|
;TI" [x, y, z]
;TI"
}
;TI" }
;TI" }
;TI" end
;TI"*# show first ten pythagorean triples
;TI"Mp pythagorean_triples.take(10).force # take is lazy, so force is needed
;TI";p pythagorean_triples.first(10) # first is eager
;TI".# show pythagorean triples less than 100
;TI">p pythagorean_triples.take_while { |*, z| z < 100 }.force;T:@format0:
@fileI"enumerator.c;T:0@omit_headings_from_table_of_contents_below0I"e.lazy -> lazy_enumerator
;T0[ I"();T@(FI"Enumerable;TcRDoc::NormalModule00