[#61171] Re: [ruby-changes:33145] normal:r45224 (trunk): gc.c: fix build for testing w/o RGenGC — SASADA Koichi <ko1@...>
(2014/03/01 16:15), normal wrote:
[#61243] [ruby-trunk - Feature #9425] [PATCH] st: use power-of-two sizes to avoid slow modulo ops — normalperson@...
Issue #9425 has been updated by Eric Wong.
[#61359] [ruby-trunk - Bug #9609] [Open] [PATCH] vm_eval.c: fix misplaced RB_GC_GUARDs — normalperson@...
Issue #9609 has been reported by Eric Wong.
(2014/03/07 19:09), [email protected] wrote:
SASADA Koichi <[email protected]> wrote:
[#61424] [REJECT?] xmalloc/xfree: reduce atomic ops w/ thread-locals — Eric Wong <normalperson@...>
I'm unsure about this. I _hate_ the extra branches this adds;
Hi Eric,
SASADA Koichi <[email protected]> wrote:
(2014/03/14 2:12), Eric Wong wrote:
SASADA Koichi <[email protected]> wrote:
(2014/03/15 17:34), Eric Wong wrote:
[#61452] [ruby-trunk - Feature #9632] [Open] [PATCH 0/2] speedup IO#close with linked-list from ccan — normalperson@...
Issue #9632 has been reported by Eric Wong.
[#61496] [ruby-trunk - Feature #9638] [Open] [PATCH] limit IDs to 32-bits on 64-bit systems — normalperson@...
Issue #9638 has been reported by Eric Wong.
[#61568] hash function for global method cache — Eric Wong <normalperson@...>
I came upon this because I noticed existing st numtable worked poorly
(2014/03/18 8:03), Eric Wong wrote:
SASADA Koichi <[email protected]> wrote:
what's the profit from using binary tree in place of hash?
Юрий Соколов <[email protected]> wrote:
[#61687] [ruby-trunk - Bug #9606] Ocassional SIGSEGV inTestException#test_machine_stackoverflow on OpenBSD — normalperson@...
Issue #9606 has been updated by Eric Wong.
[#61760] [ruby-trunk - Feature #9632] [PATCH 0/2] speedup IO#close with linked-list from ccan — normalperson@...
Issue #9632 has been updated by Eric Wong.
[ruby-core:61190] [ruby-trunk - Feature #7444] Array#product_set
Issue #7444 has been updated by Marc-Andre Lafortune.
Duplicated by Feature #8970: Array.zip and Array.product added
----------------------------------------
Feature #7444: Array#product_set
https://bugs.ruby-lang.org/issues/7444#change-45550
* Author: Marc-Andre Lafortune
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: core
* Target version: next minor
----------------------------------------
I'd like to propose `Array#product_set` to return the product set of arrays (aka cartesian product)
deck = [1..13, %i(spades hearts diamond clubs)].product_set
# => <#Enumerator ...>
deck.first(2) # => [[1, :spades], [2, :spades]]
`product_set` would return an enumerator if no block is given. It should raise an error if an element of the array is not an Enumerable, like Array#transpose or #zip do.
Although `Array.product` would be acceptable too, I feel that an instance method of array is best in the case, in the same way that `transpose` is an instance method and not a class method.
The name "product_set" is a correct mathematical term. Although the synonym "cartesian_product" would also be acceptable, I propose "product_set" because it is shorter and cute too. I feel it is even clearer than `product`; the first time I head of `product` I was convinced that `[2,3,7].product # => 42`.
Addressing objections raised in #6499:
1) This is not for the sake of symmetry, but because often we have an array of the arrays we want a product of.
It is cumbersome to write `arrays.first.product(*arrays[1..-1])` or similar and it hides what is going on.
Writing `arrays.product_set` is much nicer.
2) The goal is not mainly to get a lazy version, but more to make the API better. The fact that it returns an Enumerator if no block is given is just a bonus :-)
3) [].product_set.to_a # => [[]]
This can be seen from a cardinality argument, or for example because `array.repeated_permutation(n) == Array.new(n, array).product_set.to_a` and `array.repeated_permutation(0) == [[]]`.
--
http://bugs.ruby-lang.org/