diff --git a/lib/functional.rb b/lib/functional.rb index a7dbac6..632ae9d 100644 --- a/lib/functional.rb +++ b/lib/functional.rb @@ -152,14 +152,12 @@ class Functional push Collect.new( &exe) end - # map/reduce? - def map &exe - push Map.new( &exe) + def map *a, &exe + raise "Reserved for MapReduce. Install TokyoCabinet, if you want to use it." end - # map/reduce? - def reduce &exe - raise "Reserved for MapReduce." + def reduce *a, &exe + raise "Reserved for MapReduce. Install TokyoCabinet, if you want to use it." end def select &exe @@ -187,11 +185,17 @@ class Functional end def each &exe + return self unless exe push Each.new push exe run end + def join deli + push Inject.new('') {|i,j|i+deli+j} + run + end + def run @obj.send @func||:each, *@args, &@next.method(:call) @next.end @@ -201,3 +205,31 @@ class Functional each &Kernel.method( :p) end end + +begin + require 'tokyocabinet' + + class Functional + class Map