Michael G Schwern:
# You can do it with a map without much trouble:
#
# my @indexes = map { /condition/ ? $i++ : () } @stuff;
Unless I'm mistaken, that won't work, since $i only gets incremented on
matches. I think this:
my @indexes = map { $i++; /condition/ ? $i : () } @stuff;
From: Brent Dax [EMAIL PROTECTED]
Date: Thu, 5 Dec 2002 00:28:52 -0800
Michael G Schwern:
# You can do it with a map without much trouble:
#
# my @indexes = map { /condition/ ? $i++ : () } @stuff;
Unless I'm mistaken, that won't work, since $i only gets incremented on
matches. I
Michael G Schwern writes:
I'd love to be able to do it with a grep like thing.
(@switches, @args) = seperate /^-/, @ARGV;
Yes. I've written that function in Perl 5, which isn't ideal, because you
have to return array refs, not arrays.
However, I don't think it should be called
Aaron Crane:
However, I don't think it should be called 'seperate'. I also don't think
it should be called 'separate', because that word seems to be commonly
misspelled...
That seems like an excellent argument for calling it 'separate'. Perhaps it
will be the first of many spelling-improving
Michael G Schwern wrote:
and that's just entirely too much work. I'd love to be able to do
it with a grep like thing.
(@switches, @args) = seperate /^-/, @ARGV;
seperate() simply returns two lists. One of elements which match,
one of elements which don't. I think Perl 6 will allow
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
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,
On Thursday, December 5, 2002, at 10:09 AM, Michael Lazzaro wrote:
What about divvy (or are we already using that for something else?)
my(@a,@b) = divvy { ... } @c;
Other possibilities from the ol' thesaurus: Callot, Cdeal,
Cdole, Cdispense.
@$#@%*. Trying to do too many %#@%@ things
On Thursday, December 5, 2002, at 07:53 AM, Austin Hastings wrote:
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(...);
This is a terribly important question,
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
Date: Wed, 4 Dec 2002 18:26:17 -0800
From: Michael G Schwern [EMAIL PROTECTED]
Content-Disposition: inline
Sender: Michael G Schwern [EMAIL PROTECTED]
X-SMTPD: qpsmtpd/0.12, http://develooper.com/code/qpsmtpd/
(The post about 'purge'
On Wed, Dec 04, 2002 at 08:08:48PM -0700, Luke Palmer wrote:
About your idea, though, I'm rather indifferent. However, a friend of
mine once asked me if Perl had search or find operation, returning
the Iindex of matching elements. Now am I just being braindead, or
is Perl actually missing
Date: Wed, 4 Dec 2002 19:21:27 -0800
From: Michael G Schwern [EMAIL PROTECTED]
On Wed, Dec 04, 2002 at 08:08:48PM -0700, Luke Palmer wrote:
About your idea, though, I'm rather indifferent. However, a friend of
mine once asked me if Perl had search or find operation, returning
the Iindex
12 matches
Mail list logo