2013-12-09 Functional Collection Patterns | Reduce Pattern FunctionalCollectionPattern 概要 Reduce Pattern 詳細 Collectionの全ての要素を元にスカラー値を返す。 Rubyではreduce(inject)が該当。 サンプル # encoding: utf-8 list = [1, 2, 3, 4] p list.reduce(0) {|sum, e|sum += e} 結果 10 参考 http://www.ugrad.cs.jhu.edu/~wsix/collections.pdf