28 lines
622 B
Markdown
28 lines
622 B
Markdown
# infiniyield
|
|
|
|
Infinitely unfold values on-demand from a function.
|
|
|
|
[](https://hex.pm/packages/infiniyield)
|
|
[](https://hexdocs.pm/infiniyield/)
|
|
|
|
```sh
|
|
gleam add infiniyield@1
|
|
```
|
|
```gleam
|
|
import infiniyield
|
|
|
|
pub fn main() {
|
|
infiniyield.unfold(2, fn(acc) { yielder.Next(acc, acc * 2) })
|
|
|> infiniyield.take(5)
|
|
// -> [2, 4, 8, 16, 32]
|
|
}
|
|
```
|
|
|
|
Further documentation can be found at <https://hexdocs.pm/infiniyield>.
|
|
|
|
## Development
|
|
|
|
```sh
|
|
gleam run # Run the project
|
|
gleam test # Run the tests
|
|
```
|