Re: Gather/take & return, PHP7-style

2015-12-09 Thread yary
My example perl6 code is wrong (and gives the correct answer by accident); and gather/take aren't exactly coroutines although I see that someone's created a "coro/yield" module at https://github.com/marcoonroad/Coro-Simple/ I have some more reading and thinking to do...

Gather/take & return, PHP7-style

2015-12-09 Thread yary
I was perusing PHP7's features, and tried some examples of their enhanced "yield" in Perl6. The first was pretty easy, the second I haven't figured out. Curious what yinz can do. Here's the first: ==php== The above example will output: 1 2 3 4 ===p6=== (Condensed) sub gen {gather {take 1; take