--- 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 > 90}]; > > or > > @a = @grades[-> x { $x > 90}]; > > or > > my StudentGrade @grades; > > @a = @grades[.isPassing]; > > I could see that as being useful. > > Of potentially more use would be: > > %grades = { Tom => 85, Mary => 95 }; > %a_students = %grades{-> $name, $grade { $grade > 90 } }; > print keys %a_students; # 'Mary'
This is what makes designing an OODB so much fun. for keys %minima -> $gr { @grades{ $gr } = grep { .getGrade() >= $minima[$gr] }, @class; } This kind of searching is too easy in a transparent language like SQL, "SELECT * FROM class WHERE curr_grade >= %min", but it's miserable when you have to "honor the objects". Being able to say something like: @grades{ $gr } = @class «st» {.getGrade() >= $minima[$gr]}; makes for a decent start. Combining vectorizing with objects can help us build a more intuitive way to talk about operations over collections. Which kind of suggests that that idea of a standardized Collections interface isn't so unreasonable, after all -- I think there's value in being able to invoke map or grep or zip, etc., on an arbitrary collector (array, hash, lol, <stream>) and have it work in a consistent, predictable manner. (But this kind of thing can be a module, or be an extension, so long as the core collection types aren't blatantly incompatible.) («st» is, of course, the vectorized "such that" operator (aka grep). I shan't demand a single-character punctuation operator... :0) =Austin __________________________________________________ Do you Yahoo!? HotJobs - Search new jobs daily now http://hotjobs.yahoo.com/