java-generator-functions icon indicating copy to clipboard operation
java-generator-functions copied to clipboard

Add a lambda implementation

Open TheRamenChef opened this issue 7 years ago • 2 comments

This pull request adds three new classes for a lambda implementation of Generator.

TheRamenChef avatar Nov 28 '18 19:11 TheRamenChef

Thanks. Do you have some examples of their usage?

mherrmann avatar Nov 29 '18 08:11 mherrmann

For example:

new LambdaGenerator<Integer>(g -> {
    g.yield(0);
    for (int i = 0; i < 10; i++) {
        g.yield(i);
        for (int j = 0; j < 10; j++) {
            g.yield(i + j);
            for (int k = 0; k < 10; k++)
                g.yield(i + j + k);
        }
    }
});

TheRamenChef avatar Nov 29 '18 12:11 TheRamenChef