On Fri, Nov 11, 2005 at 08:42:44AM -0500, Joe Gottman wrote:
: Do functions like map and grep, which in Perl5 return lists, return
: Iterators in Perl6?

A list may contain iterators.  Lists don't eagerly flatten in Perl 6.

: Can an Iterator be passed to a function (like map and grep again)
: that requires a list as an input?

Certainly.  You can pass as many iterators as you like.  The range object
is your prototypical iterator, and you can say:

    @results = grep {...} 0..9, 20..29, 40..49;

The list that grep is returning can also function as an iterator, so
@results isn't necessarily "all there" after the statement executes.

Though it's possible that = should put more COW requirements on the
right side than := would, so we at least maintain the appearance of
eager evaluation.

: Does an array or hash have only one Iterator or can it have several
: independent ones?

An array can have as many iterators as it likes, according to A6.  There's
an underlying .specs objects that contains the specifications for how
to genererate "missing" values, and if the specs are smart enough, they
can be generated from either end.

Larry

Reply via email to