I redefined function fold using reduce method in Ruby.
fold
reduce
def fold(f, init, lst) lst.reduce(init){|w, a| f.call(w, a)} end <
def fold(f, init, lst) lst.reduce(init){|w, a| f.call(w, a)} end