Exemplo n.º 1
0
func Reduce(iter collect.Iterator,
	fun func(*interface{}, interface{}),
	init interface{}) interface{} {
	for iter.HasNext() {
		fun(&init, iter.Next())
	}
	return init
}
Exemplo n.º 2
0
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)
}
Exemplo n.º 3
0
func ForEach(iter collect.Iterator, fun func(interface{})) {
	for iter.HasNext() {
		fun(iter.Next())
	}
}