Packages

Put your function in a loop until the cycle (pun intended) breaks

Current section

Files

Jump to
cycle README.md
Raw

README.md

# cycle
[![Package Version](https://img.shields.io/hexpm/v/cycle)](https://hex.pm/packages/cycle)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/cycle/)
```sh
gleam add cycle@1
```
```gleam
import cycle
pub fn main() -> Nil {
echo cycle.start(with: #([], 0), run: fn(state) {
let #(is, i) = state
case i < 5 {
True -> {
let i = i + 1
cycle.continue(#(list.prepend(is, i), i))
}
_ -> cycle.stop(is)
}
})
// output: [5, 4, 3, 2, 1]
}
```
Further documentation can be found at <https://hexdocs.pm/cycle>.
## Development
```sh
gleam run # Run the cycle
gleam test # Run the tests
```