flatten added
This commit is contained in:
parent
28dee69c07
commit
95a3027926
|
@ -154,6 +154,12 @@ class Functional
|
|||
end
|
||||
end
|
||||
|
||||
class Flatten <Base
|
||||
def call a
|
||||
Array === a ? a.each( &method( :call)) : @next.call( a)
|
||||
end
|
||||
end
|
||||
|
||||
class Reduce <Base
|
||||
def initialize iv, *a, &e
|
||||
super *a, &e
|
||||
|
@ -218,6 +224,10 @@ class Functional
|
|||
push TopDown.new( init, &exe)
|
||||
end
|
||||
|
||||
def flatten
|
||||
push Flatten.new
|
||||
end
|
||||
|
||||
def each &exe
|
||||
return self unless exe
|
||||
push Each.new
|
||||
|
|
Reference in a new issue