Skip to content

bliink-io/iterago

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Iterago

push_master codecov Go Report Card Go Reference

iterago is an iterator library.

Installation

go get github.com/ulphidius/iterago

Multihreading

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.

Examples

Filter

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)

Map

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)

Reduce

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)

Licence

This project is under MIT licence.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%