iterago
is an iterator library.
go get github.com/ulphidius/iterago
Iterago can execute its functions with a defined number of go routines. The number of go routine is defined by the environment variable ITERAGO_THREADS.
slice := []uint{1, 2, 4, 8, 16, 32, 64, 128, 256, 512}
// Filters all values upper than 128 and get back a slice of uint
result := iterago.Filter(slice, func(x uint) bool { return x <= 128 })
// Should display [1 2 4 8 16 32 64 128]
fmt.Println(result)
slice := []uint{1, 2, 4, 8, 16, 32, 64, 128, 256, 512}
// Transforms all unsigned int values into a string
result := iterago.Map(slice, func(x uint) string { return fmt.Sprintf("%d", x) })
// Should display [1 2 4 8 16 32 64 128 256 512]
fmt.Println(result)
slice := []uint{1, 2, 4, 8, 16, 32, 64, 128, 256, 512}
// Add up all the unsigned int values
result := iterago.Reduce(slice, 0, func(x, y uint) uint { return x + y })
// Should display 1023
fmt.Println(result)
This project is under MIT licence.