Server IP : 111.118.215.189 / Your IP : 216.73.216.153 Web Server : Apache System : Linux md-in-83.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 User : a1673wkz ( 2475) PHP Version : 8.2.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /proc/thread-self/root/opt/cpanel/ea-ruby24/root/usr/share/ri/system/Enumerable/ |
[ Home ] | [ C0mmand ] | [ 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