Infinitely unfold values on-demand from a function
Find a file
Lily Rose a387c0a8f7
Some checks are pending
test / test (push) Waiting to run
Fix docs typo
2025-08-09 19:04:47 +10:00
.github/workflows Initial commit 2025-08-09 18:40:17 +10:00
src Fix docs typo 2025-08-09 19:04:47 +10:00
test Initial commit 2025-08-09 18:40:17 +10:00
.gitignore Initial commit 2025-08-09 18:40:17 +10:00
gleam.toml Initial commit 2025-08-09 18:40:17 +10:00
manifest.toml Initial commit 2025-08-09 18:40:17 +10:00
README.md Move attribution to end of readme 2025-08-09 18:53:01 +10:00

infiniyield

Infinitely unfold values on-demand from a function.

Package Version Hex Docs

The library allows you to operate on an infinite sequence of values, retrieving values from the sequence as required.

gleam add infiniyield@1
import infiniyield

pub fn main() {
  infiniyield.unfold(2, fn(acc) { infiniyield.Next(acc, acc * 2) })
  |> infiniyield.take(5)
  // -> [2, 4, 8, 16, 32]
}

Based on the gleam_yielder library by Louis Pilfold.

Further documentation can be found at https://hexdocs.pm/infiniyield.