Packages

Recurse on a closure and break when done.

Current section

Files

Jump to
recur README.md
Raw

README.md

# recur

```gleam
import recur

pub fn main() -> Nil {
  echo recur.with(with: #([], 0), run: fn(state) {
    let #(is, i) = state
    case i < 5 {
      True -> {
        let i = i + 1
        recur.Continue(#(list.prepend(is, i), i))
      }
      _ -> recur.Break(is)
    }
  })

  // output: [5, 4, 3, 2, 1]
}
```
`recur` started as a fork of https://hex.pm/packages/cycle

## Provenance
This repository only contains artisanal code, i.e., no AI generation is used to implement any functionality.

## LICENSE
`recur` is made available under the terms of the EUPL-1.2 License.