Re: purge: opposite of grep

2002-12-13 Thread arcadi shehter
Damian Conway writes: > Famous last words. ;-) > > > > Was it ever decided what C would look like with multiple streams? > > for zip(@x, @y, @z) -> $x, $y, $z {...} > > and its operator version: > > for @x ¦ @y ¦ @z -> $x, $y, $z {...} > > > > Maybe we could just use

Re: purge: opposite of grep

2002-12-09 Thread Damian Conway
Brent Dax wrote: It just occurred to me that C is almost a specialization of C. Consider the results if you assign without binding: sub comparator { when /hi/ { 0 } when /lo/ { 1 } default { 2 } } @input = qw(high low hi lo glurgl); @out1 = part comparator @input; @out2 = sort {

Re: 'hashkey context/Str context' (was Re: purge: opposite of grep)

2002-12-09 Thread Damian Conway
Dave Storrs wrote: My understanding was that in Perl6, you could use pretty much anything for a hashkey--string, number, object, whatever, and that it did not get mashed down into a string. Did I have this wrong? Not wrong. But it's not the default. The default is Str keys only. But I take you

Re: purge: opposite of grep

2002-12-09 Thread Damian Conway
Ken Fox wrote: > Sometimes array references behave as arrays, e.g. > > push $array, 1 > > In flattening context array refs don't flatten, only arrays. > I'm not even sure that only arrays flatten either -- it might > be anything that begins with @. e.g. > > my Point @p; > ($x, $y) := @p; > >

Re: purge: opposite of grep

2002-12-09 Thread Damian Conway
Smylers wrote: If the initial release of Perl 6 doesn't have commonly-required functions then people will write their own. People will do these in incompatible ways, ensuring that when it's determined that the language would benefit from having a particular function built in at least some people

Re: purge: opposite of grep

2002-12-09 Thread Dan Sugalski
At 8:07 PM + 12/9/02, Smylers wrote: Perl 6.0.0 can't be perfect, but please can we aim to be as close as possible. Releasing a language with the caveat "but we've missed out lots of important functions that we expect to add in the next version or four" strikes me as a little odd. I think w

Re: 'hashkey context/Str context' (was Re: purge: opposite of grep)

2002-12-09 Thread Luke Palmer
> Date: Sun, 8 Dec 2002 21:52:33 -0800 > From: Dave Storrs <[EMAIL PROTECTED]> > > On Sat, Dec 07, 2002 at 01:28:41PM +1100, Damian Conway wrote: > > Dave Whipp wrote: > > > > > I notice everyone still want Int context for eval of the block: > > > Pease don't forget about hashes. Is there such a t

Re: purge: opposite of grep

2002-12-09 Thread Smylers
Ken Fox wrote: > If C is not a method or multimethod, then it acts like a > reserved word or built-in, like C or C. IMHO that's name > space pollution. Yes, it is namespace pollution, but I don't think that's a problem in Perl. Many other languages have functions in the same namespace as variab

'hashkey context/Str context' (was Re: purge: opposite of grep)

2002-12-09 Thread Dave Storrs
On Sat, Dec 07, 2002 at 01:28:41PM +1100, Damian Conway wrote: > Dave Whipp wrote: > > > I notice everyone still want Int context for eval of the block: > > Pease don't forget about hashes. Is there such a thing as > > 'hashkey context'? > > I doubt it. Unless you count Str context. My understan

RE: purge: opposite of grep

2002-12-09 Thread Brent Dax
It just occurred to me that C is almost a specialization of C. Consider the results if you assign without binding: sub comparator { when /hi/ { 0 } when /lo/ { 1 } default { 2 } } @input = qw(high low hi lo glurgl)

Re: purge: opposite of grep

2002-12-08 Thread Ken Fox
Damian Conway wrote: Ken Fox asked: Is it correct to think of flattening context as a lexical flattening? i.e. only terms written with @ are flattened and the types of the terms can be ignored? I'm not sure I understand this question. Sometimes array references behave as arrays, e.g. push

Re: purge: opposite of grep

2002-12-08 Thread Damian Conway
David Wheeler wrote: Ooh, I like C best. C is too easy to interpret as other things (partition? part with? part from? part of? partner? etc.). You know, that's *exactly* why I like C better. ;-) Damian

Re: purge: opposite of grep

2002-12-08 Thread Damian Conway
Ken Fox asked: sub part ($classifier, *@list) { return @parts; } Given the original example (@foo,@bar,@zap) := part [ /foo/, /bar/, /zap/ ] @source; this binds the contents of @parts to (@foo,@bar,@zap)? Yes. The array refs in @parts are not flattened though

Re: purge: opposite of grep

2002-12-08 Thread David Wheeler
On Sunday, December 8, 2002, at 10:20 AM, Smylers wrote: I dislike C cos it's a small typo away from C. Yes, but I would expect to be a compile-time error, since the signatures are different. The same can't be said for r?index. David -- David Wheeler AIM:

Re: purge: opposite of grep

2002-12-08 Thread Smylers
David Wheeler wrote: > On Saturday, December 7, 2002, at 10:47 PM, Damian Conway wrote: > > > Ian Remmler decloaked and wrote: > > > > > I keep thinking C would be nice ... > > > > C is quite good. Though I still like C best. > > Ooh, I like C best. I dislike C cos it's a small typo away from

Re: purge: opposite of grep

2002-12-08 Thread David Wheeler
On Saturday, December 7, 2002, at 10:47 PM, Damian Conway wrote: I keep thinking C would be nice, or maybe C. Just a thought... C is quite good. Though I still like C best. Ooh, I like C best. C is too easy to interpret as other things (partition? part with? part from? part of? partner? et

Re: purge: opposite of grep

2002-12-08 Thread Ken Fox
Damian Conway wrote: sub part ($classifier, *@list) { return @parts; } Given the original example (@foo,@bar,@zap) := part [ /foo/, /bar/, /zap/ ] @source; this binds the contents of @parts to (@foo,@bar,@zap)? The array refs in @parts are not flattened though. Is it c

Re: purge: opposite of grep

2002-12-08 Thread Ian Remmler
On Sun, Dec 08, 2002 at 11:28:24AM +1100, Damian Conway wrote: > We could certainly do that. But let's call it C. I usually just lurk here, but I just had to pipe in. :) I'm not sure the meaning of the name C would be obvious to someone who hadn't seen it before. I keep thinking C would be nice,

Re: purge: opposite of grep

2002-12-08 Thread Simon Cozens
[EMAIL PROTECTED] (Damian Conway) writes: > Of course, as long as you can call C without explicitly loading > a module, it's merely a philosophical distinction as to whether > C is core or not. Well, no; it's an implementation distinction too. Non-core methods 1) don't mean anything special to

Re: purge: opposite of grep

2002-12-07 Thread Damian Conway
Ian Remmler decloaked and wrote: I'm not sure the meaning of the name C would be obvious > to someone who hadn't seen it before. What, as opposed to C or C or C or C or C or C or C or C or C or C or C or C or C or...? ;-) I keep thinking C would be nice, or maybe C. Just a thought... C i

Re: purge: opposite of grep

2002-12-07 Thread Damian Conway
Michael Lazzaro wrote: If we're worried about the distance between the source and destination when there are many tests Are we? I'm not. maybe: part { /foo/ => @foo, /bar/ => @bar, /zap/ => @zap }, @source; Or, 'long' formatted: part { /foo/ => @foo, /bar/ => @bar,

Re: purge: opposite of grep

2002-12-07 Thread Michael Lazzaro
Damian Conway wrote: > (@foo,@bar,@zap) := part [/foo/, /bar/, /zap/], @source; If we're worried about the distance between the source and destination when there are many tests, maybe: part { /foo/ => @foo, /bar/ => @bar, /zap/ => @zap }, @source; Or, 'long' formatted: part {

Re: purge: opposite of grep

2002-12-07 Thread Damian Conway
ralph wrote: Presumably, to avoid run time errors, that would need to be something like: push (/foo/ && @foo || /bar/ && @bar || /zap/ && @zap || @void), $_ for @source; True. Why not: part ( @source, /foo/ => @foo, /bar/ => @bar, /zap/ => @zap ); Because C, C,

Re: purge: opposite of grep

2002-12-07 Thread Damian Conway
Simon Cozens wrote: A categorise method would be just grand, and I think it should be shipped with the default Perl 6 array classes, but Perl 6 The Core Language wouldn't need to know about that particular method if it didn't want to. Err. Since arrays are core to Perl 6, how could their method

Re: purge: opposite of grep

2002-12-07 Thread Me
> push (/foo/ && @foo || > /bar/ && @bar || > /zap/ && @zap), $_ for @source; Presumably, to avoid run time errors, that would need to be something like: push (/foo/ && @foo || /bar/ && @bar || /zap/ && @zap || @void), $_ for @source; > But perhaps... > >

Re: purge: opposite of grep

2002-12-07 Thread Simon Cozens
[EMAIL PROTECTED] (Damian Conway) writes: > > Why does everything have to be built into the first version of Perl 6? > > Everything doesn't. Everything shouldn't be. Just the really common, > important stuff. > > I have to confess though, there are *many* times I've wished for > this particular

Re: purge: opposite of grep

2002-12-07 Thread Damian Conway
Damian Conway wrote: Et voilà: Or, of those who prefer their code sanely formatted: sub part ($classifier, *@list) { my &classify := convert_to_sub($classifier); my @parts; for @list -> $nextval { my $index = try{ classify($nextval) } // next;

Re: purge: opposite of grep

2002-12-07 Thread Damian Conway
Ken Fox asked: How about just (@foo,@bar,@zap) := classify [ rx/foo/, rx/bar/, rx/zap/ ] @source; and implement classify as a normal sub? We could certainly do that. But let's call it C. Et voilà: sub part ($classifier, *@list) { my &classify := convert_to_sub($classifier); my

Re: purge: opposite of grep

2002-12-07 Thread Tanton Gibbs
> Damian Conway wrote: > > or even a arrayed form, when the corresponding index was implicit: > > > > (@foo,@bar,@zap) := part [/foo/, /bar/, /zap/], @source; > > That's kinda nifty. But admittedly, it's not to-die-for necessary, if > I'm the only one fond of it. I think this makes a nice

Re: purge: opposite of grep

2002-12-07 Thread Michael Lazzaro
Damian Conway wrote: > or even a arrayed form, when the corresponding index was implicit: > > (@foo,@bar,@zap) := part [/foo/, /bar/, /zap/], @source; That's kinda nifty. But admittedly, it's not to-die-for necessary, if I'm the only one fond of it. Ken Fox wrote: > and implement class

Re: purge: opposite of grep

2002-12-07 Thread Ken Fox
Michael Lazzaro wrote: (@foo,@bar,@zap) := classify { /foo/ ;; /bar/ ;; /zap/ } @source; A shorthand for: for @source { given { when /foo/ { push @foo, $_ } when /bar/ { push @bar, $_ } when /zap/ { push @zap, $_ } } } How about just (@foo,@bar,@

Re: purge: opposite of grep

2002-12-07 Thread Damian Conway
Michael Lazzaro wrote: (@foo,@bar,@zap) := classify { /foo/ ;; /bar/ ;; /zap/ } @source; A shorthand ... that "classifies" (or "parts") @source according to > the results of a series of tests, not just one. You mean, like: (@foo,@bar,@zap) := part { when /foo/ {0}; when /bar/ {1}; when

Re: purge: opposite of grep

2002-12-07 Thread Michael Lazzaro
Damian Conway wrote: > > Michael Lazzaro wrote: > > > How would you do something like: > > > > (@foo,@bar,@zap) := classify { /foo/ ;; /bar/ ;; /zap/ } @source; > > Since I don't understand what that's supposed to do, I probably *wouldn't* > do something like it. What effect are you trying t

RE: purge: opposite of grep

2002-12-06 Thread Brent Dax
Damian Conway: # > Also, can I return superpositions (sorry, junctions), to provide # > multiple classifications? Or would I return an array for that? # # A (dis)junction ought to work there. That sounds horribly scary... --Brent Dax <[EMAIL PROTECTED]> @roles=map {"Parrot $_"} qw(embedding reg

Re: purge: opposite of grep

2002-12-06 Thread Damian Conway
Michael Lazzaro wrote: How would you do something like: (@foo,@bar,@zap) := classify { /foo/ ;; /bar/ ;; /zap/ } @source; Since I don't understand what that's supposed to do, I probably *wouldn't* do something like it. What effect are you trying to achieve? Damian

Re: purge: opposite of grep

2002-12-06 Thread Damian Conway
Dave Whipp wrote: I notice everyone still want Int context for eval of the block: Pease don't forget about hashes. Is there such a thing as 'hashkey context'? I doubt it. Unless you count Str context. Perl6 is much better than Perl5 for naming parameters. Could we make the following work?

Re: purge: opposite of grep

2002-12-06 Thread Damian Conway
ralph wrote: I worry that C sounds too much like something class-related 'Classify' also seems wrong if some items are thrown away. I like 'part': (@foo,@bar) := part { ... } @source; ralph and I don't often agree, but I certainly do in this case. I like C very much as a name for this buil

Re: purge: opposite of grep

2002-12-06 Thread Aaron Crane
Sean O'Rourke writes: > On Thu, 5 Dec 2002, Sean O'Rourke wrote: > > how 'bout "tang" for "Tog's A Negated Grep"? > > Gah. s/Tog/Tang/. Wouldn't that mean we had to rename grep to 'gnat'? ("Gnat's Not A Tang", presumably, never mind rot13 and reversal...) -- Aaron Crane * GBdirect Ltd. http:/

Re: purge: opposite of grep

2002-12-06 Thread Sean O'Rourke
On Thu, 5 Dec 2002, Sean O'Rourke wrote: > On 5 Dec 2002, Rafael Garcia-Suarez wrote: > > John Williams wrote in perl.perl6.language : > > If you want good'ol Unix flavor, call it "vrep". Compare the ed(1) / > > ex(1) / vi(1) commands (where 're' stands for regular expression, of > > course) : > >

Re: purge: opposite of grep

2002-12-06 Thread Sean O'Rourke
On 5 Dec 2002, Rafael Garcia-Suarez wrote: > John Williams wrote in perl.perl6.language : > If you want good'ol Unix flavor, call it "vrep". Compare the ed(1) / > ex(1) / vi(1) commands (where 're' stands for regular expression, of > course) : > :g/re/p > :v/re/p Or, to follow the spirit r

Re: purge: opposite of grep

2002-12-06 Thread Me
Michael said: > I worry that C sounds too much like > something class-related 'Classify' also seems wrong if some items are thrown away. I like 'part': (@foo,@bar) := part { ... } @source; Headed off in another direction, having a sub distribute its results like this reminds me of: ... -> .

Re: purge: opposite of grep

2002-12-06 Thread Tim Conrow
Michael Lazzaro wrote: I worry that C sounds too much like something class-related, and would confuse people. What about C or something? Decent thesaurus entries for include: assign, classify, comb, compartmentalize, discriminate, distribute, group, order, segregate, sift, winnow, amputate, c

Re: purge: opposite of grep

2002-12-06 Thread Dave Whipp
"Michael Lazzaro" <[EMAIL PROTECTED]> wrote > > Some of those might be appropriate (or just amusing). :-) I still like partition (or simply C). Segregate (c) might also work I notice everyone still want Int context for eval of the block: Pease don't forget about hashes. Is there such a thing as

Re: purge: opposite of grep

2002-12-06 Thread Michael Lazzaro
On Thursday, December 5, 2002, at 07:55 PM, Damian Conway wrote: equally. The built-in would actually be doing classification of the elements of the list, so it ought to be called C. I worry that C sounds too much like something class-related, and would confuse people. What about C or someth

Re: purge: opposite of grep

2002-12-06 Thread Graham Barr
On Fri, Dec 06, 2002 at 09:33:14AM -0500, Miko O'Sullivan wrote: > For example, suppose I want to separate a list of people into people who > have never donated money and those who have. Assuming that each person > object has a donations property which is an array reference, I would want > to clas

Re: purge: opposite of grep

2002-12-06 Thread Miko O'Sullivan
On Fri, 6 Dec 2002, Damian Conway wrote: > The selector block/closure would, naturally, be called in C context > each time, so (again, as Larry pointed out) a boolean function would > naturally classify into two arrays. Though it might at first be a little > counterintuitive to have to write: OK,

Re: purge: opposite of grep

2002-12-05 Thread Damian Conway
I would suggest that we could get away with a single n-ary built-in. And I would strongly suggest that C isn't the right name for it, since, apart from being a ugly, slang word, "divvy" implies dividing up equally. The built-in would actually be doing classification of the elements of the list, so

Re: purge: opposite of grep

2002-12-05 Thread Austin Hastings
--- Dave Whipp <[EMAIL PROTECTED]> wrote: > > I think that c would be an abysmal name: that implies > "keep the false ones". I'm not sure that there is a synonym > for "boolean partition" though. Perhaps we need some help > from a linguist! ;) > What's wrong with split()? split { f($_) }, $ite

Re: purge: opposite of grep

2002-12-05 Thread Miko O'Sullivan
On 5 Dec 2002, Rafael Garcia-Suarez wrote: > If you want good'ol Unix flavor, call it "vrep". Compare the ed(1) / > ex(1) / vi(1) commands (where 're' stands for regular expression, of > course) : > :g/re/p > :v/re/p I like it. Fits in with our Un*x heritage, and doesn't have any existin

Re: purge: opposite of grep

2002-12-05 Thread Dave Whipp
"Miko O'Sullivan" <[EMAIL PROTECTED]> wrote: > On Thu, 5 Dec 2002, Dave Whipp wrote: > > > Only if we apply a bit of magic (2 is a true value). The rule might be: > > How about if we just have two different methods: one for boolean and one > for multiple divvies: > > my(@true, @false) := @array.c

Re: purge: opposite of grep

2002-12-05 Thread Rafael Garcia-Suarez
John Williams wrote in perl.perl6.language : > > While "purge" is cute, it certainly is not obvious what it does. Of > course neither is "grep" unless you are an aging unix guru... > > How about something which is at least obvious to someone who knows what > grep is, such as "vgrep" or "grep:v"?

Re: purge: opposite of grep

2002-12-05 Thread Miko O'Sullivan
On Thu, 5 Dec 2002, Dave Whipp wrote: > Only if we apply a bit of magic (2 is a true value). The rule might be: How about if we just have two different methods: one for boolean and one for multiple divvies: my(@true, @false) := @array.cull{/some test/}; my (@a, @b, @c) := @array.divvy{some co

RE: purge: opposite of grep

2002-12-05 Thread Fisher Mark
> FWIW, I came up with "purge" because my first inclination was to spell > "grep" backwards: "perg". :-) I like "purge", although "except", "exclude", and "omit" all have their charms. For partition function, I like "divvy", "carve", "segment" (in that order) and almost anything other than "sepa

Re: purge: opposite of grep

2002-12-05 Thread Dave Whipp
"Larry Wall" <[EMAIL PROTECTED]> wrote: > On Thu, Dec 05, 2002 at 10:09:08AM -0800, Michael Lazzaro wrote: > : What about "divvy" (or are we already using that for something else?) > : > : my(@a,@b) = divvy { ... } @c; > > Any such solution must use := rather than =. I'd go as far as to say >

Re: purge: opposite of grep

2002-12-05 Thread Larry Wall
On Thu, Dec 05, 2002 at 10:09:08AM -0800, Michael Lazzaro wrote: : What about "divvy" (or are we already using that for something else?) : : my(@a,@b) = divvy { ... } @c; Any such solution must use := rather than =. I'd go as far as to say that divvy should be illegal in a list context. Not

Re: purge: opposite of grep

2002-12-05 Thread Miko O'Sullivan
On Thu, 5 Dec 2002, Robert Spier wrote: > -R (who does not see any benefit of 'perg' over grep { ! code } ) My problem with grep { ! code } is the same problem I have with if (! expression): I've never developed a real trust in operator precedence. Even looking at your pseudocode example, I itche

Re: purge: opposite of grep

2002-12-05 Thread Robert Spier
>How about my original inclinaton: "perg"? It just screams out "the >opposite of grep". So it greps a list in reverse order? -R (who does not see any benefit of 'perg' over grep { ! code } )

Re: purge: opposite of grep

2002-12-05 Thread Miko O'Sullivan
On Wed, 4 Dec 2002, John Williams wrote: > While "purge" is cute, it certainly is not obvious what it does. Of > course neither is "grep" unless you are an aging unix guru... > > How about something which is at least obvious to someone who knows what > grep is, such as "vgrep" or "grep:v"? How a

Re: purge: opposite of grep

2002-12-05 Thread Adam D. Lopresto
I like it except for the name, which feels too active to me (ie, if I were to purge those elements from the array I'd expect the array to be altered, instead of returning a new array with only those elements). But I do like the idea. I think the name "except" would be pretty nice, though. Then a

Re: purge: opposite of grep

2002-12-05 Thread Michael Lazzaro
On Wednesday, December 4, 2002, at 09:11 PM, John Williams wrote: On Wed, 4 Dec 2002, Miko O'Sullivan wrote: FWIW, I came up with "purge" because my first inclination was to spell "grep" backwards: "perg". :-) While "purge" is cute, it certainly is not obvious what it does. Of course neit

Re: purge: opposite of grep

2002-12-05 Thread Simon Cozens
[EMAIL PROTECTED] (Miko O'Sullivan) writes: > FWIW, I came up with "purge" because my first inclination was to spell > "grep" backwards: "perg". :-) For reference, Ruby uses .detect and .reject. -- 3rd Law of Computing: Anything that can go wr fortune: Segmentation violation -- Core dum

Re: purge: opposite of grep

2002-12-04 Thread John Williams
On Wed, 4 Dec 2002, Miko O'Sullivan wrote: > > FWIW, I came up with "purge" because my first inclination was to spell > "grep" backwards: "perg". :-) While "purge" is cute, it certainly is not obvious what it does. Of course neither is "grep" unless you are an aging unix guru... How about somet

RE: purge: opposite of grep

2002-12-04 Thread David Whipp
Miko O'Sullivan [mailto:[EMAIL PROTECTED]] wrote: > SUMMARY > > Proposal for the "purge" command as the opposite of "grep" in > the same way that "unless" is the opposite of "if". I like it. But reading it reminded me of another common thing I do with grep: partitioning a list into equivalence

purge: opposite of grep

2002-12-04 Thread Miko O'Sullivan
SUMMARY Proposal for the "purge" command as the opposite of "grep" in the same way that "unless" is the opposite of "if". DETAILS I've lately been going a lot of greps in which I want to keep all the elements in an array that do *not* match some rule. For example, suppose I have a list of membe