On Mon Feb 22 14:43:21 2016, greg.lon...@infineon.com wrote:
> 
> Current format for a lazily evaluated list:
> 
> my $lazylist = (0, { $_ + 3 } ...^ * > 10);
> 
> ^*> is incoherent line noise.

Thanks for trying out Perl 6.

In case this wasn't just a rant, the ^ here is tied to the sequence, and means
exclude the endpoint. For example, 1...^4 produces a three element sequence.

The * is a Whatever star, and is ubiquitous in Perl 6. It's a way to generate
a closure; * > 10 here means "something greater than 10". So altogether,
...^ * > 10 should read, a sequence up to , but not including, a value greater 
than 10.

So, as it turns out, this isn't really a list that needs lazifying, it's only 
got 
4 elements: 0, 3, 6, 9. The 12 is greater than 10, so we take everything up to 
but
not including it.

> Please consider making a builtin function that looks kind of like a
> "for loop" but is lazily evaluated.
> 
> my $lazylist = lazy ($_=0; $_ <= 10; $_+=3);
> 
> The syntax for a FOR() loop is well established and already has
> everything needed to define a lazy list.
> (start condition; end condition; increment condition)

In Perl 6, the C-style for loop you reference is spelled "loop".

loop (my $i = 0; $i < 10; $i++) { say $i } # prints out 0 to 9.
 
> Keep the line noise version if you want, but a lazy() function would
> be much more natural and intuitive for oddball situations and would
> need almost zero explanation.

Turns out we already have a "lazy". So this code works today.

my $lazylist = lazy loop (my $i=0; ; $i++) { $i };
say $lazylist[1000];

Rejecting ticket. I encourage you to checkout docs.perl6.org
and/or stop by on the irc channel if you have more questions.

-- 
Will "Coke" Coleda

Reply via email to