Thank you, moritz, for your explanation, and in the process, for introducing me to several aspects of Perl6 I was unfamiliar with.

I am indeed seeking to build an indefinite list of closures, each one having an incremented value of $n. If this seems an odd request, then rest assured it's only because I've rendered this as an isolated, simplified problem for posting here; the more complex application uses an analogous data structure in an elemental way.

Your first suggestion...

my @blocks := (0..*).map: -> $n { -> $x, $y { $x * $y * $n } };

...seems just right, but it hangs rakudo-star-2012.04.

Your second suggestion...

sub gen($x, $y) { state $n = 0; $x*$y*$n++ } my @foo := &gen xx *;

...is, as you suggested, not what I'm looking for, because I want $n to reflect the ordinal position in the series, not the ordinal call order of the closure.

Your third suggestion...

my @foo := sub ($x, $y) { state $n = 0; $x*$y*$n++ } xx *;

...gives every element of @foo the same ordinal position in the series (0), and re-accessing @foo[0], say, increments $n for @foo[0]'s closure, whereas I want it to be static indicator of ordinal position in the series.

Given what you said about the sequence operator (...) trying to invoke my closure, I realized that what I need is the equivalent of prime (') in CL/Scheme, and to properly scope the ordinal incrementor $n.

So this is my solution...

my @foo = { state $n=-1; $n++; sub ($x,$y) { $x+$y+$n } } ... *;
...which when accessed in the following manner...
for 0..2 -> $i { for 0..2 { say @foo[$i](3,5); } say; }
...will produce the following output...
8 8 8 9 9 9 10 10 10

In reply to Re^2: Perl6 lazy list of code blocks by aes
in thread Perl6 lazy list of code blocks by aes

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.