In thinking about how to write a "partition" function (or separate, or
whatever you want to call it) it occurs to me that you might want some
sort of reverse-varargs behavior, like

my (@a, @b, @c, @d) = @array.partiton { $_ % 4 };

So in this case, partition is supposed to determine, on the fly, how
many classes to return (or return all the classes it makes, and let an
exception take mismatches).

How do we do that? 

And in general, without resorting to something hideous like scanf, is
there going to be some more-advanced want() variant that allows saying

@a, $i, $j, @b, %w, $k, @c = scramble(...);

??

=Austin


--- HellyerP <[EMAIL PROTECTED]> wrote:
> Angel Faus:
> > Maybe the solution is to make it hash-wise:
> > 
> > %hash = @array.sep {
> >         when /^[A-Z]*$/ {'uppercase'}
> >         when /^[a-z]*$/ {'lowercase'}
> >         default         {'mixedcase'}
> > }
> 
> I agree that general partitioning is 'better' than a fixed binary
> proposal,
> but what is gained over the full code except a tiny bit of sugar?
> 
> for (@array)
> {
>     when /^[A-Z]+$/ { push %hash{'uppercase'}, $_ }
>     when /^[a-z]+$/ { push %hash{'lowercase'}, $_ }
>     default         { push %hash{'mixedcase'}, $_ }
> }
> 
> On the other hand, perhaps binary-partitioning is sufficiently common
> to
> warrant Schwern's abbreviated syntax:
> 
> (@switches, @args) = separate /^-/, @ARGV;
> 
> Which in full would be something like:
> 
> for (@ARGV)
> {
>     when /^-/ { push @switches, $_ }
>     default   { push @args, $_ }
> }
> 
> Philip
> 
> 
> Disclaimer
> 
> This communication together with any attachments transmitted with it
> ('this E-mail') is intended only for the use of the addressee and may
> contain information which is privileged and confidential. If the
> reader of this E-mail is not the intended recipient or the employee
> or agent responsible for delivering it to the intended recipient you
> are notified that any use of this E-mail is prohibited. Addressees
> should ensure this E-mail is checked for viruses. The Carphone
> Warehouse Group PLC makes no representations as regards the absence
> of viruses in this E-mail. If you have received this E-mail in error
> please notify our ISe Response Team immediately by telephone on + 44
> (0)20 8896 5828 or via E-mail at [EMAIL PROTECTED] Please then
> immediately destroy this E-mail and any copies of it.
> 
> Please feel free to visit our website: 
> 
> UK
> http://www.carphonewarehouse.com
> 
> Group
> http://www.phonehouse.com
> 
> 

Reply via email to