--- Dave Whipp <[EMAIL PROTECTED]> wrote:
> 
> I think that c<cull> would be an abysmal name: that implies
> "keep the false ones". I'm not sure that there is a synonym
> for "boolean partition" though. Perhaps we need some help
> from a linguist! ;)
> 

What's wrong with split()?

split { f($_) }, $iterator    -or- @array.split { f($_) }

vs.

split /\Q$delim\E/, $string   -or- $string.split( /\Q$delim\E/ )


BTW, since it's possible to say:

my (@even, @odd) = split { $_ % 2 }, 0 .. Inf;

I presume that split will be smart enough to be usefully lazy. So
laziness is probably a contagious property. (If the input is lazy, the
output probably will be, too.)

But what happens with side-effects, or with pathologically ordered
accesses?

That is, iterators tend to get wrapped with a lazy array, which caches
the accesses.

So if the discriminator function caches values of its own, what
happens?

E.g.,

# Side-effects
my (@even, @odd) 
    = split { is_prime($_) && $last_prime = $_; $_ % 2 }, 0..Inf;

The value of last_prime is .. ?

# Pathological access:
my (@even, @odd) = ... as above ...

print $#odd;

Does @even (which is going to be cached by the lazy array) just swamp
memory, or what?


=Austin



=Austin

Reply via email to