It was a matter of time, of course, after my last thread.

How often do we want chunks of a string or list? And how often do we
abuse a temporary copy and substr/splice for that?

What if instead of

    my @copy = @array;
    while (my @chunk = splice @copy, 0, $chunksize) {
        ...
    }  # ^1

we could just write

    for @array [/] $chunksize -> @chunk { ... }

and instead of 

    my $copy = $string;
    while (defined(my $chunk = substr $copy, 0, $chunksize)) {
        ...
    }  # ^2

we could use

    for $string ~/ $chunksize -> $chunk { ... }

I think it'd make life much easier.

Of course, [/] is subject to the same discussion as the other thread,
and should perhaps be (/) or */.


Juerd

PS. http://tnx.nl/3689VBOF  # consistency gone mad (expires in 1 day)

^1 Yes, I know it can be made more efficient by using the "list
reference" trick, sub { [EMAIL PROTECTED] }->(LIST).
^2 Same thing, but with \substr. Too bad there is only one LVALUE,
because you can't keep a reference around. Will this be fixed in P6?
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html

Reply via email to