[#39222] [Bug #2036] AIX 5L 5.2にて、ruby-1.8.7-p174のビルド時にmake testをするとエラーになった。not ok float 7 -- ./sample/test.rb:1232 — 和弥 寺元 <redmine@...>
Bug #2036: AIX 5L 5.2にて、ruby-1.8.7-p174のビルド時にmake testをするとエラーになった。not ok float 7 -- ./sample/test.rb:1232
チケット #2036 が更新されました。 (by 和弥 寺元)
[#39248] pdeque - Double-Ended Priority Queue — Tanaka Akira <akr@...>
優先順位つきキューとして、このメールにつけてある pdeque.rb
[#39249] [Bug #2060] DLをCからRubyに変換する事を勧めます — Aaron Patterson <redmine@...>
Bug #2060: DLをCからRubyに変換する事を勧めます
なかだです。
2009/9/7 Nobuyoshi Nakada <[email protected]>:
[#39277] Why doesn't Array#product return Enumerator? — Yusuke ENDOH <mame@...>
遠藤です。
まつもと ゆきひろです
遠藤です。
まつもと ゆきひろです
[#39282] [Bug #2067] bodyが大きいエラーページをopen-uriで取得するとfdがリークしている — takeru sasaki <redmine@...>
チケット #2067 が更新されました。 (by takeru sasaki)
まつもと ゆきひろです
なかだです。
まつもと ゆきひろです
In article <[email protected]>,
言いだしっぺの佐々木です。
まつもと ゆきひろです
佐々木です。
In article <[email protected]>,
[#39301] [Feature #2080] Proc#to_source, Method#to_source — Yuki Sonoda <redmine@...>
Feature #2080: Proc#to_source, Method#to_source
[#39322] [Feature #2093] String#stripの対象は\sか[:space:]か — Yui NARUSE <redmine@...>
Feature #2093: String#stripの対象は\sか[:space:]か
[#39325] makeターゲットrdevを抽象化 — "KISHIMOTO, Makoto" <[email protected]>
きしもとです
[#39352] [ruby19] Thread 切替えが異常に遅い? — Hidetoshi NAGAI <nagai@...>
永井@知能.九工大です.
なかだです。
永井@知能.九工大です.
ささだです.
永井@知能.九工大です.
なかだです。
[#39361] [Bug:1.9] ("00".."00").to_a => ["0"] — Nobuhiro IMAI <nov@...>
いまいです。
[#39367] Almost endless loop of BigMath::atan(x) when x.abs >= 1 — "Masahiro Kanai (CanI)" <cani.m.61st@...>
金井 仁弘と申します。
豊福です。遅い反応ですが。
豊福です。
金井です。
豊福です。
豊福です。
豊福です。
金井です。
[#39372] [Proposal] メンテナ確認大会のお知らせ — Yugui <yugui@...>
Yuguiです。
WXVndWkbJEIkNSRzJWEhPCVrJCIkaiQsJEgkJiQ0JDYkJCReJDckPyEjJDMkQSRpJEtKVj8uJDck
[#39385] Removing constant-able macros inside of the loop. — "Masahiro Kanai (CanI)" <cani.m.61st@...>
金井 仁弘と申します。
[#39388] Re: [ruby-cvs:32331] Ruby:r25113 (trunk): String#inspect's encoding should be fixed. — "Martin J. Dürst" <duerst@...>
成瀬さん、こんにちは。
こんにちは、なかむら(う)です。
成瀬です。
中村さん、成瀬さん、こんにちは。
MjAwOeW5tDnmnIgyOeaXpTEyOjMxICJNYXJ0aW4gSi4gRMO8cnN0IiA8ZHVlcnN0QGl0LmFveWFt
[#39404] [ANN] Ruby Developer's Meeting 20091013 — Yugui <yugui@...>
Yuguiです。
[ruby-dev:39277] Why doesn't Array#product return Enumerator?
遠藤です。
Array#product は Enumerator でなく配列を返しますが、何か理由が
あってのことでしょうか。
Array#permutation や combination のように Enumerator を返した方が
自然かつ便利だと思います。これらのメソッドは brute force 的な探索に
よく使いますが、product だけ探索前に巨大な配列を確保してしまうので
いやらしいです。
仕様変更になってしまいますが、一応言ってみました。どうでしょうか。
Index: array.c
===================================================================
--- array.c (revision 24823)
+++ array.c (working copy)
@@ -3858,30 +3858,35 @@
* call-seq:
* ary.product(other_ary, ...)
*
- * Returns an array of all combinations of elements from all arrays.
- * The length of the returned array is the product of the length
- * of ary and the argument arrays
+ * When invoked with a block, yields all combinations of elements
+ * from all arrays.
*
- * [1,2,3].product([4,5]) # => [[1,4],[1,5],[2,4],[2,5],[3,4],[3,5]]
- * [1,2].product([1,2]) # => [[1,1],[1,2],[2,1],[2,2]]
- * [1,2].product([3,4],[5,6]) # => [[1,3,5],[1,3,6],[1,4,5],[1,4,6],
- * # [2,3,5],[2,3,6],[2,4,5],[2,4,6]]
- * [1,2].product() # => [[1],[2]]
- * [1,2].product([]) # => []
+ * When invoked without a block, returns an enumerator object instead.
+ *
+ * [1,2,3].product([4,5]).to_a # =>
[[1,4],[1,5],[2,4],[2,5],[3,4],[3,5]]
+ * [1,2].product([1,2]).to_a # => [[1,1],[1,2],[2,1],[2,2]]
+ * [1,2].product([3,4],[5,6]).to_a # => [[1,3,5],[1,3,6],[1,4,5],[1,4,6],
+ * # [2,3,5],[2,3,6],[2,4,5],[2,4,6]]
+ * [1,2].product().to_a # => [[1],[2]]
+ * [1,2].product([]).to_a # => []
*/
static VALUE
rb_ary_product(int argc, VALUE *argv, VALUE ary)
{
int n = argc+1; /* How many arrays we're operating on */
- volatile VALUE t0 = tmpbuf(n, sizeof(VALUE));
- volatile VALUE t1 = tmpbuf(n, sizeof(int));
- VALUE *arrays = (VALUE*)RSTRING_PTR(t0); /* The arrays we're
computing the product of */
- int *counters = (int*)RSTRING_PTR(t1); /* The current position in
each one */
- VALUE result; /* The array we'll be returning */
+ volatile VALUE t0, t1;
+ VALUE *arrays;
+ int *counters;
long i,j;
long resultlen = 1;
+ RETURN_ENUMERATOR(ary, argc, argv);
+ t0 = tmpbuf(n, sizeof(VALUE));
+ t1 = tmpbuf(n, sizeof(int));
+ arrays = (VALUE*)RSTRING_PTR(t0); /* The arrays we're computing
the product of */
+ counters = (int*)RSTRING_PTR(t1); /* The current position in each one */
+
RBASIC(t0)->klass = 0;
RBASIC(t1)->klass = 0;
@@ -3903,7 +3908,6 @@
}
/* Otherwise, allocate and fill in an array of results */
- result = rb_ary_new2(resultlen);
for (i = 0; i < resultlen; i++) {
int m;
/* fill in one subarray */
@@ -3913,7 +3917,7 @@
}
/* put it on the result array */
- rb_ary_push(result, subarray);
+ rb_yield(subarray);
/*
* Increment the last counter. If it overflows, reset to 0
@@ -3930,7 +3934,7 @@
tmpbuf_discard(t0);
tmpbuf_discard(t1);
- return result;
+ return ary;
}
/*
Index: test/ruby/test_array.rb
===================================================================
--- test/ruby/test_array.rb (revision 24823)
+++ test/ruby/test_array.rb (working copy)
@@ -1306,14 +1306,14 @@
def test_product
assert_equal(@cls[[1,4],[1,5],[2,4],[2,5],[3,4],[3,5]],
- @cls[1,2,3].product([4,5]))
- assert_equal(@cls[[1,1],[1,2],[2,1],[2,2]], @cls[1,2].product([1,2]))
+ @cls[1,2,3].product([4,5]).to_a)
+ assert_equal(@cls[[1,1],[1,2],[2,1],[2,2]], @cls[1,2].product([1,2]).to_a)
assert_equal(@cls[[1,3,5],[1,3,6],[1,4,5],[1,4,6],
[2,3,5],[2,3,6],[2,4,5],[2,4,6]],
- @cls[1,2].product([3,4],[5,6]))
- assert_equal(@cls[[1],[2]], @cls[1,2].product)
- assert_equal(@cls[], @cls[1,2].product([]))
+ @cls[1,2].product([3,4],[5,6]).to_a)
+ assert_equal(@cls[[1],[2]], @cls[1,2].product.to_a)
+ assert_equal(@cls[], @cls[1,2].product([]).to_a)
end
def test_permutation
--
Yusuke ENDOH <[email protected]>