Iter provides functionality like Python's range function to iterate over numbers and letters
Install the package using
$ go get github.com/thedevsaddam/iter
To use the package import it in your *.go
code
import "github.com/thedevsaddam/iter"
Let's see a quick example:
package main
import (
"fmt"
"github.com/thedevsaddam/iter"
)
func main() {
// sequence: 0-9
for v := range iter.N(10) {
fmt.Printf("%d ", v)
}
fmt.Println()
// output: 0 1 2 3 4 5 6 7 8 9
// sequence: 5-9
for v := range iter.N(5, 10) {
fmt.Printf("%d ", v)
}
fmt.Println()
// output: 5 6 7 8 9
// sequence: 1-9, increment by 2
for v := range iter.N(5, 10, 2) {
fmt.Printf("%d ", v)
}
fmt.Println()
// output: 5 7 9
// sequence: a-e
for v := range iter.L('a', 'e') {
fmt.Printf("%s ", string(v))
}
fmt.Println()
// output: a b c d e
}
If you encounter any bugs or issues, feel free to open an issue at github.
Also, you can shoot me an email to mailto:thedevsaddam@gmail.com for hugs or bugs.
If you are interested to make the package better please send pull requests or create an issue so that others can fix. Read the contribution guide here
The iter is an open-source software licensed under the MIT License.