Piers Cawley pointed out:
%a_students = grep {.key ~~ :i/^a/}, %grades.kv;
I think you could probably get away without the .kv there since, in a
list context you're going to get a list of pairs anyway.
In fact, the code is invalid as it stands. The following variations
work as desired:
%a_s
"Adam D. Lopresto" <[EMAIL PROTECTED]> writes:
>> I don't see why I'd want to do it with arrays, but...
>>
>> %a_students = %grades{grep /^a/i, keys %grades};
>
> Looks like that's just the same as
>
> %a_students = grep {.key ~~ :i/^a/}, %grades.kv;
I think you could probably get away without
On Wed, Nov 06, 2002 at 11:36:50AM -0800, Larry Wall wrote:
> You know, guys, I already discussed this one in A4 or thereabouts.
> It's the use of an explicit boolean operator as a subscript that
> triggers selection.
I thought so, but I couldn't find it.
thanks,
-Scott
--
Jonathan Scott Duff
[
> I don't see why I'd want to do it with arrays, but...
>
> %a_students = %grades{grep /^a/i, keys %grades};
Looks like that's just the same as
%a_students = grep {.key ~~ :i/^a/}, %grades.kv;
(after adjusting for perl6 syntax for a few things)
--
Adam Lopresto ([EMAIL PROTECTED])
http://cec.
You know, guys, I already discussed this one in A4 or thereabouts.
It's the use of an explicit boolean operator as a subscript that
triggers selection.
Larry
> Will there be some shorter-hand way to say these?
> [list comprehensions]
(bb clarified that this is about hash slicing.)
>From A2:
RFC 201: Hash Slicing
...Concise list comprehensions will require
some other syntax within the subscript...
And
There are many ways
--- Buddha Buck <[EMAIL PROTECTED]> wrote:
> I think that if there were a slice-based form of grep, it would most
> likely look like you are indexing by a subroutine (or method)
> reference
> that takes no arguments other than an element of the array.
> Something like:
>
>@a = @grades[{$^x
Piers Cawley wrote:
Jonathan Scott Duff <[EMAIL PROTECTED]> writes:
Will there be some shorter-hand way to say these?
@a = @grades[grep $_ >= 90, @grades];
@b = @grades[grep 80 <= $_ < 90, @grades];
@c = @grades[grep 70 <= $_ < 80, @grades];
Granted, it's fairly compact as it is but I'm wo
Jonathan Scott Duff wrote:
On Wed, Nov 06, 2002 at 12:54:12PM -0500, Mark J. Reed wrote:
On 2002-11-06 at 11:43:20, Jonathan Scott Duff wrote:
Will there be some shorter-hand way to say these?
@a = @grades[grep $_ >= 90, @grades];
@b = @grades[grep 80 <= $_ < 90, @grades];
@c = @grades[gre
[EMAIL PROTECTED] (Piers Cawley) writes:
> I confess I never quite understood why the python folks were so proud
> of list comprehensions, AFAICT they're just 'grep' and 'map' given
> fancy descriptions.
Well, sort of. They're more like this:
@arr
@a = @grades[$^_ >= 90];
> @b = @grades[80 <= $^_ < 90];
> @c = @grades[70 <= $^_ < 80];
>
> BTW, is there some other name for these things? I only know to call
> them "list comprehensions" from python. I've used the conce
On Wed, Nov 06, 2002 at 12:54:12PM -0500, Mark J. Reed wrote:
>
> On 2002-11-06 at 11:43:20, Jonathan Scott Duff wrote:
> >
> > Will there be some shorter-hand way to say these?
> >
> > @a = @grades[grep $_ >= 90, @grades];
> > @b = @grades[grep 80 <= $_ < 90, @grades];
> > @c = @gra
On 2002-11-06 at 11:43:20, Jonathan Scott Duff wrote:
>
> Will there be some shorter-hand way to say these?
>
> @a = @grades[grep $_ >= 90, @grades];
> @b = @grades[grep 80 <= $_ < 90, @grades];
> @c = @grades[grep 70 <= $_ < 80, @grades];
I think what you mean here is just
#x27;s
some way to not have to mention @grades twice per statement.
Something like:
@a = @grades[$^_ >= 90];
@b = @grades[80 <= $^_ < 90];
@c = @grades[70 <= $^_ < 80];
BTW, is there some other name for these things? I only know to call
them "list comprehens
"raptor" <[EMAIL PROTECTED]> writes:
| hi,
| I haven't used Python... but last days I read some stuff, wanted to compare
| both languages for myself and found something interesting.
| They are proposing extentinon to Pyhon 2
It's already in Python 2.0.
--
http://www.dfan.org
Simon Cozens wrote:
> On Sun, Oct 08, 2000 at 01:12:13PM +0100, raptor wrote:
> > [ for in ]
> > Can this be done easly at the moment OR via some of the new proposals
?!!!?
>
> map { expression } sequence
>
See also RFC 81.
On Sun, Oct 08, 2000 at 01:12:13PM +0100, raptor wrote:
> [ for in ]
> Can this be done easly at the moment OR via some of the new proposals ?!!!?
map { expression } sequence
--
I used to be disgusted, now I find I'm just amused.
-- Elvis Costello
#x27;s for features addition in Perl 7,8,9,10 ;") )
Can this be done easly at the moment OR via some of the new proposals ?!!!?
Does this have some benefit compared to array creation via cycles .... !!!
List Comprehensions
This is a flexible new notation for lists whose elements ar
18 matches
Mail list logo