|
| 1 | +iter |
| 2 | +--- |
| 3 | +[](https://travis-ci.org/thedevsaddam/iter) |
| 4 | +[](https://github.com/thedevsaddam/iter/releases) |
| 5 | +[](https://goreportcard.com/report/github.com/thedevsaddam/iter) |
| 6 | +[](https://coveralls.io/github/thedevsaddam/iter) |
| 7 | +[](https://pkg.go.dev/github.com/thedevsaddam/iter) |
| 8 | +[](LICENSE.md) |
| 9 | + |
| 10 | +Iter provides functionality like Python's range function to iterate over numbers and letters |
| 11 | + |
| 12 | +### Installation |
| 13 | + |
| 14 | +Install the package using |
| 15 | +```go |
| 16 | +$ go get github.com/thedevsaddam/iter |
| 17 | +``` |
| 18 | + |
| 19 | +### Usage |
| 20 | + |
| 21 | +To use the package import it in your `*.go` code |
| 22 | +```go |
| 23 | +import "github.com/thedevsaddam/iter" |
| 24 | +``` |
| 25 | + |
| 26 | +Let's see a quick example: |
| 27 | + |
| 28 | +```go |
| 29 | +package main |
| 30 | + |
| 31 | +import ( |
| 32 | + "fmt" |
| 33 | + |
| 34 | + "github.com/thedevsaddam/iter" |
| 35 | +) |
| 36 | + |
| 37 | +func main() { |
| 38 | + // sequence: 0-9 |
| 39 | + for v := range iter.N(10) { |
| 40 | + fmt.Printf("%d ", v) |
| 41 | + } |
| 42 | + fmt.Println() |
| 43 | + // output: 0 1 2 3 4 5 6 7 8 9 |
| 44 | + |
| 45 | + // sequence: 5-9 |
| 46 | + for v := range iter.N(5, 10) { |
| 47 | + fmt.Printf("%d ", v) |
| 48 | + } |
| 49 | + fmt.Println() |
| 50 | + // output: 5 6 7 8 9 |
| 51 | + |
| 52 | + // sequence: 1-9, increment by 2 |
| 53 | + for v := range iter.N(5, 10, 2) { |
| 54 | + fmt.Printf("%d ", v) |
| 55 | + } |
| 56 | + fmt.Println() |
| 57 | + // output: 5 7 9 |
| 58 | + |
| 59 | + // sequence: a-e |
| 60 | + for v := range iter.L('a', 'e') { |
| 61 | + fmt.Printf("%s ", string(v)) |
| 62 | + } |
| 63 | + fmt.Println() |
| 64 | + // output: a b c d e |
| 65 | +} |
| 66 | + |
| 67 | +``` |
| 68 | + |
| 69 | + |
| 70 | +## Bugs and Issues |
| 71 | + |
| 72 | +If you encounter any bugs or issues, feel free to [open an issue at |
| 73 | +github](https://github.com/thedevsaddam/iter/issues). |
| 74 | + |
| 75 | +Also, you can shoot me an email to |
| 76 | +<mailto:thedevsaddam@gmail.com> for hugs or bugs. |
| 77 | + |
| 78 | +## Contribution |
| 79 | +If you are interested to make the package better please send pull requests or create an issue so that others can fix. |
| 80 | +[Read the contribution guide here](CONTRIBUTING.md) |
| 81 | + |
| 82 | + |
| 83 | +## License |
| 84 | +The **iter** is an open-source software licensed under the [MIT License](LICENSE.md). |
0 commit comments