[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: [PATCH 5.005_63] Open-ended slices: (a..z)[23..]
gsar@activestate.com wrote:
> Interesting idea, but I think I'd want it to be more general than
> what you've got there.
I had a feeling someone was going to say that. :)
> print @a[3..]; # fourth item to the last
We can do this, but for lists.
> print @a[-2..]; # last three items
We can do this, but for lists. I looked into doing the two
above for arrays, but I got scared.
> print @a[1..-2]; # second through third-last
I had something like this working before, but MJD pointed out
x..y where x>y already has a meaning - it's defined in perlop
to return an empty list. At least a completely new syntax
doesn't break stuff. If you like, I'll play with it, though.
> print @a[..-2]; # first through third-last
Breaking intuition with $a[-1] being the final element
because...?
> print @a[..]; # everything (useless?)
@a[$x..$y] - who's to say that $x and $y can't be undef oh
my gosh.
> print (1,2,3)[1..-2]; # empty-list/error/reverse(1,2) ???
Uhm. I'd say empty list. Interesting.
Simon
- Follow-Ups from:
-
Gurusamy Sarathy <gsar@ActiveState.com>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]