Re: list comprehensions

2002-11-07 Thread Damian Conway
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

Re: list comprehensions

2002-11-06 Thread Piers Cawley
"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

Re: list comprehensions

2002-11-06 Thread Jonathan Scott Duff
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 [

Re: list comprehensions

2002-11-06 Thread Adam D. Lopresto
> 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.

Re: list comprehensions

2002-11-06 Thread Larry Wall
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

Re: list comprehensions

2002-11-06 Thread Me
> 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 we could re

Re: list comprehensions

2002-11-06 Thread Austin Hastings
--- 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

Re: list comprehensions

2002-11-06 Thread Buddha Buck
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

Re: list comprehensions

2002-11-06 Thread Buddha Buck
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

Re: list comprehensions

2002-11-06 Thread Simon Cozens
[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: @array[grep { func() } 0..$#array] -- "If you

Re: list comprehensions

2002-11-06 Thread Piers Cawley
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'

Re: list comprehensions

2002-11-06 Thread Jonathan Scott Duff
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

Re: list comprehensions

2002-11-06 Thread Mark J. Reed
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

Re: List Comprehensions (from Python)

2000-10-17 Thread Dan Schmidt
"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

Re: List Comprehensions (from Python)

2000-10-08 Thread Jeremy Howard
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.

Re: List Comprehensions (from Python)

2000-10-08 Thread Simon Cozens
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