yary wrote:
I'm a relative beginner at perl6, but pretty good with perl5 (and C
and a few others), so I read
for 0...@foo.elems
as saying Give me a list with one item longer then @foo, not give
me the indexes of @foo.
But a Perl non-beginner did make that mistake. The problem is that it
looks
Patrick R. Michaud wrote:
An even cleaner shortcut might be to use ^...@foo instead of ^...@foo.elems:
for ^...@foo - $k { do_something($k, @foo[$k]) }
Somewhat clearer could be:
for @foo.keys - $k { do_something($k, @foo[$k]) }
And some may prefer:
for @foo.kv - $k, $v {
I don't see how you could interpret the name elems as something
returning index of the last element. If your IRC interlocutor
confused @foo.elems with $#foo, then it seems more likely that they
were confused about the semantics of $#foo than of .elems , whose p5
equivalent is just scalar(@foo).
On Tue, May 26, 2009 at 04:38:21PM -0700, yary wrote:
perl4-perl5.8 or so had a variable that let you change the starting
index for arrays, so you could actually make the above work. But then
everyone who'd re-arranged their brains to start counting at 0, and
written code that has a starting
On Wed, May 27, 2009 at 7:05 AM, John Macdonald j...@perlwolf.com wrote:
On Tue, May 26, 2009 at 04:38:21PM -0700, yary wrote:
perl4-perl5.8 or so had a variable that let you change the starting
index for arrays, so you could actually make the above work. But then
everyone who'd re-arranged
On Tue, May 26, 2009 at 9:03 PM, Patrick R. Michaud pmich...@pobox.comwrote:
On Tue, May 26, 2009 at 06:43:40PM -0500, John M. Dlugosz wrote:
Daniel Carrera daniel.carrera-at-theingots.org |Perl 6| wrote:
The following construction doesn't do what a user might expect:
for 0...@foo.elems
Is it still a global in Perl 6?
It's not even global in perl5.10. perldoc says:
As of release 5 of Perl, assignment to $[ is
treated as a compiler directive, and cannot
influence the behavior of any other file. (That's
why you can only
Jonathan Scott Duff wrote:
Or perhaps
for 0...@foo.end - $k { ... }
@foo.keys may not be what the user wanted if @foo is a sparse array.
IIRC, you have to explicitly ask for the custom index in order to get
sparse array keys. By design, the normal index is never sparse;
only the custom
You're assuming he's using an instance of the built-in Array class.
I would think one reason for implementing your own class that does
Positional is to do something out of the ordinary.
So what exactly does Positional promise? I think it should be as
general as possible, and avoid thinking
Hello,
The following construction doesn't do what a user might expect:
for 0...@foo.elems - $k { do_something($k,@foo[$k]) }
Obviously, the intention is to step through every key/value in @foo. Buf
@f...@foo.elems] does not exist. If @foo = (1,2,3); then @foo.elems is
3, and @foo[3] is
I'm a relative beginner at perl6, but pretty good with perl5 (and C
and a few others), so I read
for 0...@foo.elems
as saying Give me a list with one item longer then @foo, not give
me the indexes of @foo. I can see users being tripped up by the old
problem of we start counting at 0 and not at 1,
Daniel Carrera daniel.carrera-at-theingots.org |Perl 6| wrote:
Hello,
The following construction doesn't do what a user might expect:
for 0...@foo.elems - $k { do_something($k,@foo[$k]) }
Obviously, the intention is to step through every key/value in @foo.
Buf @f...@foo.elems] does not
On Tue, May 26, 2009 at 06:43:40PM -0500, John M. Dlugosz wrote:
Daniel Carrera daniel.carrera-at-theingots.org |Perl 6| wrote:
The following construction doesn't do what a user might expect:
for 0...@foo.elems - $k { do_something($k,@foo[$k]) }
Write ^...@foo.elems as a shortcut of
13 matches
Mail list logo