зеркало из https://github.com/github/ruby.git
* enumerator.c (enumerable_lazy): added the documenation of Enumerable#lazy.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
b681457f01
Коммит
f0f777bc4a
|
@ -1,3 +1,7 @@
|
|||
Tue Mar 13 00:09:18 2012 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* enumerator.c (enumerable_lazy): added documentation.
|
||||
|
||||
Mon Mar 12 20:19:25 2012 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* lib/tmpdir.rb (Dir::tmpdir): test the current directory suitable for
|
||||
|
|
21
enumerator.c
21
enumerator.c
|
@ -1247,6 +1247,27 @@ lazy_initialize(VALUE self, VALUE obj)
|
|||
/*
|
||||
* call-seq:
|
||||
* e.lazy -> lazy_enumerator
|
||||
*
|
||||
* Returns a lazy enumerator, whose methods map/collect,
|
||||
* flat_map/collect_concat, select/find_all, reject, and grep call blocks
|
||||
* only on an as-needed basis.
|
||||
*
|
||||
* === Example
|
||||
*
|
||||
* The following program shows all pythagorean triples less than 100:
|
||||
*
|
||||
* def pythagorean_triples
|
||||
* (1..Float::INFINITY).lazy.flat_map {|z|
|
||||
* (1..z).flat_map {|x|
|
||||
* (x..z).select {|y|
|
||||
* x**2 + y**2 == z**2
|
||||
* }.map {|y|
|
||||
* [x, y, z]
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* end
|
||||
* p pythagorean_triples.take_while { |x, y, z| z < 100 }
|
||||
*/
|
||||
static VALUE
|
||||
enumerable_lazy(VALUE obj)
|
||||
|
|
Загрузка…
Ссылка в новой задаче