https://github.com/zot/generators.jl
Lightweight, task-based generators for Julia
https://github.com/zot/generators.jl
Last synced: 8 months ago
JSON representation
Lightweight, task-based generators for Julia
- Host: GitHub
- URL: https://github.com/zot/generators.jl
- Owner: zot
- License: mit
- Created: 2021-12-09T13:48:46.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-11T17:52:01.000Z (about 4 years ago)
- Last Synced: 2025-04-15T09:55:25.094Z (12 months ago)
- Language: Julia
- Size: 6.84 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Generators
Very lightweight, task-based generators.
# Generators.jl Documentation
#
**`Generators.generate`** — *Method*.
```julia
generate(func::Function)
```
Create a generator from func. Func receives a "yield" function as its argument. You can use this function to produce values.
Here's an example of a recursive generator:
```julia
flattened(list) = generate() do yield
fl(el::Vector) = foreach(fl, el)
fl(el) = yield(el)
fl(list)
end
[flattened([1, [2, [3], 4], 5])...] == [1,2,3,4,5]
```