--20cf3054acddd8667a049734ac18
Content-Type: text/plain; charset=ISO-8859-1

Hi.

How about a method for converting enumerable to hash?

  enum.categorize([opts]) {|elt| [key1, ..., val] } -> hash

categorizes the elements in _enum_ and returns a hash.

The block is called for each elements in _enum_.
The block should return an array which contains
one or more keys and one value.

  p (0..10).categorize {|e| [e % 3, e % 5] }
  #{00, 3, 1, 4], 11, 4, 2, 0], 22, 0, 3]}

The keys and value are used to construct the result hash.
If two or more keys are provided
(i.e. the length of the array is longer than 2),
the result hash will be nested.

  p (0..10).categorize {|e| [e&4, e&2, e&1, e] }
  #{0000, 8],
  #            11, 9]},
  #        202, 10],
  #            13]}},
  #    4004],
  #            15]},
  #        206],
  #            17]}}}

The value of innermost hash is an array which contains values for
corresponding keys.
This behavior can be customized by :seed, :op and :update option.

This method can take an option hash.
Available options are follows:

- :seed specifies seed value.
- :op specifies a procedure from seed and value to next seed.
- :update specifies a procedure from seed and block value to next seed.

:seed, :op and :update customizes how to generate
the innermost hash value.
:seed and :op behavies like Enumerable#inject.

If _seed_ and _op_ is specified, the result value is generated as follows.
  op.call(..., op.call(op.call(seed, v0), v1), ...)

:update works as :op except the second argument is the block value itself
instead of the last value of the block value.

If :seed option is not given, the first value is used as the seed.

  # The arguments for :op option procedure are the seed and the value.
  # (i.e. the last element of the array returned from the block.)
  r  0].categorize(:seed :s,
                     :op lambda {|x,y|
                       p [x,y]               #[:s, :v]
                       1
                     }) {|e|
    p e #0
    [:k, :v]
  }
  p r #{:k}

  # The arguments for :update option procedure are the seed and the array
  # returned from the block.
  r  0].categorize(:seed :s,
                     :update lambda {|x,y|
                       p [x,y]               #[:s, [:k, :v]]
                       1
                     }) {|e|
    p e #0
    [:k, :v]
  }
  p r #{:k}

The default behavior, array construction, can be implemented as follows.
  :seed nil
  :op lambda {|s, v| !s ? [v] : (s << v) }

Note that matz doesn't find satisfact in the method name, "categorize".
[ruby-dev:42681]

Also note that matz wants another method than this method,
which the hash value is the last value, not an array of all values.
This can be implemented by enum.categorize(:opambda {|x,y| y}) { ... }.
But good method name is not found yet.
[ruby-dev:42643]
-- 
Tanaka Akira

--20cf3054acddd8667a049734ac18
Content-Type: text/x-diff; charset=US-ASCII; name="enum-categorize.patch"
Content-Disposition: attachment; filename="enum-categorize.patch"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_ghltshrc0

JSBzdm4gZGlmZiAtLWRpZmYtY21kIGRpZmYgLXggJy11IC1wJwpJbmRleDogZW51bS5jCj09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT0KLS0tIGVudW0uYwkocmV2aXNpb24gMzAxNDgpCisrKyBlbnVtLmMJKHdvcmtpbmcgY29w
eSkKQEAgLTE1LDcgKzE1LDcgQEAKICNpbmNsdWRlICJpZC5oIgogCiBWQUxVRSByYl9tRW51bWVy
YWJsZTsKLXN0YXRpYyBJRCBpZF9uZXh0Oworc3RhdGljIElEIGlkX25leHQsIGlkX2NhbGwsIGlk
X3NlZWQsIGlkX29wLCBpZF91cGRhdGU7CiAjZGVmaW5lIGlkX2VhY2ggaWRFYWNoCiAjZGVmaW5l
IGlkX2VxcSAgaWRFcXEKICNkZWZpbmUgaWRfY21wICBpZENtcApAQCAtMjU5NSw2ICsyNTk1LDIx
MSBAQCBlbnVtX3NsaWNlX2JlZm9yZShpbnQgYXJnYywgVkFMVUUgKmFyZ3YsCiAgICAgcmV0dXJu
IGVudW1lcmF0b3I7CiB9CiAKK3N0cnVjdCBjYXRlZ29yaXplX2FyZyB7CisgICAgVkFMVUUgc2Vl
ZDsKKyAgICBWQUxVRSBvcDsKKyAgICBWQUxVRSB1cGRhdGU7CisgICAgVkFMVUUgcmVzdWx0Owor
fTsKKworc3RhdGljIFZBTFVFCitjYXRlZ29yaXplX3VwZGF0ZShzdHJ1Y3QgY2F0ZWdvcml6ZV9h
cmcgKmFyZ3AsIFZBTFVFIGFjYywgVkFMVUUgYXJ5LCBWQUxVRSB2YWwpCit7CisgICA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FsdWUgaXRzZWxmCisgKiBp
bnN0ZWFkIG9mIHRoZSBsYXN0IHZhbHVlIG9mIHRoZSBibG9jayB2YWx1ZS4KKyAqCisgKiBJZiA6
c2VlZCBvcHRpb24gaXMgbm90IGdpdmVuLCB0aGUgZmlyc3QgdmFsdWUgaXMgdXNlZCBhcyB0aGUg
c2VlZC4KKyAqCisgKiAgICMgVGhlIGFyZ3VtZW50cyBmb3IgOm9wIG9wdGlvbiBwcm9jZWR1cmUg
YXJlIHRoZSBzZWVkIGFuZCB0aGUgdmFsdWUuCisgKiAgICMgKGkuZS4gdGhlIGxhc3QgZWxlbWVu
dCBvZiB0aGUgYXJyYXkgcmV0dXJuZWQgZnJvbSB0aGUgYmxvY2suKQorICogICByID0gWzBdLmNh
dGVnb3JpemUoOnNlZWQgPT4gOnMsCisgKiAgICAgICAgICAgICAgICAgICAgICA6b3AgPT4gbGFt
YmRhIHt8eCx5fAorICogICAgICAgICAgICAgICAgICAgICAgICBwIFt4LHldICAgICAgICAgICAg
ICAgIz0+IFs6cywgOnZdCisgKiAgICAgICAgICAgICAgICAgICAgICAgIDEKKyAqICAgICAgICAg
ICAgICAgICAgICAgIH0pIHt8ZXwKKyAqICAgICBwIGUgIz0+IDAKKyAqICAgICBbOmssIDp2XQor
ICogICB9CisgKiAgIHAgciAjPT4gezprPT4xfQorICoKKyAqICAgIyBUaGUgYXJndW1lbnRzIGZv
ciA6dXBkYXRlIG9wdGlvbiBwcm9jZWR1cmUgYXJlIHRoZSBzZWVkIGFuZCB0aGUgYXJyYXkKKyAq
ICAgIyByZXR1cm5lZCBmcm9tIHRoZSBibG9jay4KKyAqICAgciA9IFswXS5jYXRlZ29yaXplKDpz
ZWVkID0+IDpzLAorICogICAgICAgICAgICAgICAgICAgICAgOnVwZGF0ZSA9PiBsYW1iZGEge3x4
LHl8CisgKiAgICAgICAgICAgICAgICAgICAgICAgIHAgW3gseV0gICAgICAgICAgICAgICAjPT4g
WzpzLCBbOmssIDp2XV0KKyAqICAgICAgICAgICAgICAgICAgICAgICAgMQorICogICAgICAgICAg
ICAgICAgICAgICAgfSkge3xlfAorICogICAgIHAgZSAjPT4gMAorICogICAgIFs6aywgOnZdCisg
KiAgIH0KKyAqICAgcCByICM9PiB7Oms9PjF9CisgKgorICogVGhlIGRlZmF1bHQgYmVoYXZpb3Is
IGFycmF5IGNvbnN0cnVjdGlvbiwgY2FuIGJlIGltcGxlbWVudGVkIGFzIGZvbGxvd3MuCisgKiAg
IDpzZWVkID0+IG5pbAorICogICA6b3AgPT4gbGFtYmRhIHt8cywgdnwgIXMgPyBbdl0gOiAocyA8
PCB2KSB9CisgKgorICovCitzdGF0aWMgVkFMVUUKK2VudW1fY2F0ZWdvcml6ZShpbnQgYXJnYywg
VkFMVUUgKmFyZ3YsIFZBTFVFIGVudW1lcmFibGUpCit7CisgICAgVkFMVUUgb3B0czsKKyAgICBz
dHJ1Y3QgY2F0ZWdvcml6ZV9hcmcgYXJnOworCisgICAgUkVUVVJOX0VOVU1FUkFUT1IoZW51bWVy
YWJsZSwgMCwgMCk7CisKKyAgICByYl9zY2FuX2FyZ3MoYXJnYywgYXJndiwgIjA6IiwgJm9wdHMp
OworCisgICAgaWYgKE5JTF9QKG9wdHMpKSB7CisgICAgICAgIGFyZy5zZWVkID0gUW5pbDsKKyAg
ICAgICAgYXJnLm9wID0gUXVuZGVmOworICAgICAgICBhcmcudXBkYXRlID0gUXVuZGVmOworICAg
IH0KKyAgICBlbHNlIHsKKyAgICAgICAgYXJnLnNlZWQgPSByYl9oYXNoX2xvb2t1cDIob3B0cywg
SUQyU1lNKGlkX3NlZWQpLCBRdW5kZWYpOworICAgICAgICBhcmcub3AgPSByYl9oYXNoX2xvb2t1
cDIob3B0cywgSUQyU1lNKGlkX29wKSwgUXVuZGVmKTsKKyAgICAgICAgYXJnLnVwZGF0ZSA9IHJi
X2hhc2hfbG9va3VwMihvcHRzLCBJRDJTWU0oaWRfdXBkYXRlKSwgUXVuZGVmKTsKKyAgICAgICAg
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l9tRW51bWVyYWJsZSwgImNodW5rIiwgZW51bV9j
aHVuaywgLTEpOwogICAgIHJiX2RlZmluZV9tZXRob2QocmJfbUVudW1lcmFibGUsICJzbGljZV9i
ZWZvcmUiLCBlbnVtX3NsaWNlX2JlZm9yZSwgLTEpOworICAgIHJiX2RlZmluZV9tZXRob2QocmJf
bUVudW1lcmFibGUsICJjYXRlZ29yaXplIiwgZW51bV9jYXRlZ29yaXplLCAtMSk7CiAKICAgICBp
ZF9uZXh0ID0gcmJfaW50ZXJuKCJuZXh0Iik7CisgICAgaWRfY2FsbCA9IHJiX2ludGVybigiY2Fs
bCIpOworICAgIGlkX3NlZWQgPSByYl9pbnRlcm4oInNlZWQiKTsKKyAgICBpZF9vcCA9IHJiX2lu
dGVybigib3AiKTsKKyAgICBpZF91cGRhdGUgPSByYl9pbnRlcm4oInVwZGF0ZSIpOwogfQpJbmRl
eDogdGVzdC9ydWJ5L3Rlc3RfZW51bS5yYgo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSB0ZXN0L3J1YnkvdGVzdF9l
bnVtLnJiCShyZXZpc2lvbiAzMDE0OCkKKysrIHRlc3QvcnVieS90ZXN0X2VudW0ucmIJKHdvcmtp
bmcgY29weSkKQEAgLTM4NCw0ICszODQsMzMgQEAgY2xhc3MgVGVzdEVudW1lcmFibGUgPCBUZXN0
OjpVbml0OjpUZXN0QwogICAgICAgICAgICAgICAgICBzcy5zbGljZV9iZWZvcmUoL1xBLi4uXHov
KS50b19hKQogICBlbmQKIAorICBkZWYgdGVzdF9jYXRlZ29yaXplCisgICAgYXNzZXJ0X2VxdWFs
KCgxLi42KS5ncm91cF9ieSB7fGl8IGkgJSAzIH0sCisgICAgICAgICAgICAgICAgICgxLi42KS5j
YXRlZ29yaXplIHt8ZXwgW2UgJSAzLCBlXSB9KQorICAgIGFzc2VydF9lcXVhbChIYXNoWyBbIFsi
YSIsIDEwMF0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X0sCisgICAgICAgICAgICAgICAgICJm
b29iYXJiYXoiLnNwbGl0KC8vKS5jYXRlZ29yaXplKDpzZWVkPT5bXSwgOnVwZGF0ZT0+OispIHt8
Y2h8IFtjaCwgMV0gfSkKKyAgICBhc3NlcnRfcmFpc2UoQXJndW1lbnRFcnJvcikgeyBbMF0uY2F0
ZWdvcml6ZSB7fGV8IFtdIH0gfQorICAgIGFzc2VydF9yYWlzZShBcmd1bWVudEVycm9yKSB7IFsw
XS5jYXRlZ29yaXplIHt8ZXwgWzFdIH0gfQorICAgIGFzc2VydF9lcXVhbCgKKyAgICAgIHsiZiI9
PnsibyI9PnsibyI9Pns6Yz0+MX19fSwKKyAgICAgICAiYiI9PnsiYSI9PnsiciI9Pns6Yz0+MX0s
CisgICAgICAgICAgICAgICAgICAgInoiPT57OmM9PjF9fX19LAorICAgICAgJXdbZm9vIGJhciBi
YXpdLmNhdGVnb3JpemUoOm9wPT46Kykge3xzfCBzLnNwbGl0KC8vKSArIFs6YywgMV0gfSkKKyAg
ICAjYXNzZXJ0X3JhaXNlKFR5cGVFcnJvcikgeyBbWzEsIDJdLCBbMSwgMiwgM11dLmNhdGVnb3Jp
emUge3xlfCBlIH0gfQorICBlbmQKKwogZW5kCg--20cf3054acddd8667a049734ac18--