[].to_fun.reduce( []) # => Ups. [] will not be duped, so every key will have the same value.
Argument for #reduce removed and everytime it will be an Array.
This commit is contained in:
parent
a97c4ed1f9
commit
70e8c7ea29
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
class ::Regexp
|
class ::Regexp
|
||||||
class NegRegexp
|
class NegRegexp
|
||||||
def initialize r
|
def initialize r
|
||||||
|
@ -193,10 +192,9 @@ class Functional
|
||||||
end
|
end
|
||||||
|
|
||||||
class Reduce <Base
|
class Reduce <Base
|
||||||
def initialize iv, *a, &e
|
def initialize *a, &e
|
||||||
super *a, &e
|
super *a, &e
|
||||||
@buf = {}
|
@buf = Hash.new {|h,k| h[k] = []}
|
||||||
@buf.default = iv
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def call *a
|
def call *a
|
||||||
|
@ -302,8 +300,8 @@ class Functional
|
||||||
push Map.new( &exe)
|
push Map.new( &exe)
|
||||||
end
|
end
|
||||||
|
|
||||||
def reduce iv, &exe
|
def reduce &exe
|
||||||
push Reduce.new( iv, &exe)
|
push Reduce.new( &exe)
|
||||||
end
|
end
|
||||||
|
|
||||||
def select &exe
|
def select &exe
|
||||||
|
|
Reference in a new issue