An open API service indexing awesome lists of open source software.

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

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]
```