func Reduce(iter collect.Iterator, fun func(*interface{}, interface{}), init interface{}) interface{} { for iter.HasNext() { fun(&init, iter.Next()) } return init }
func Listify(it collect.Iterator) collect.List { list := &collect.LinkedList{} for it.HasNext() { list.Append(it.Next()) } return list //return (algo.Reduce(it, func(list *interface{}, e interface{}) { // ((*list).(collect.List)).Append(e) //}, &collect.LinkedList{})).(collect.List) }
func ForEach(iter collect.Iterator, fun func(interface{})) { for iter.HasNext() { fun(iter.Next()) } }