Luke Palmer wrote:
So I suppose that's my proposal. Allow, even encourage, overloading
of =:=, but only for value types. I've been thinking that we ought to
provide a standard role for making something a value type. Maybe it
would require definition of =:=.
I would like to propose something
Mark Overmeer wrote:
'uniq' differs from 'sort' because there is no order relationship between
the elements. A quick algorithm for finding the unique elements in perl5
is
sub uniq(@)
{ my %h = map { ($_ => 1) } @elements;
keys %h;
}
...and an even quicker one is:
use Set::Object;
Luke wrote:
I wondered what uniq's default comparator should be, =:=?
&infix:<~~>
Woah there. ~~ is a good comparator and all, but it's not the right
one here. ~~ compares an object and a pattern to see if they match.
That makes it the right choice for when and grep. But we're trying to
remov
On 5/19/05, Damian Conway <[EMAIL PROTECTED]> wrote:
> Ingo Blechschmidt wrote:
> > I wondered what uniq's default comparator should be, =:=?
>
> &infix:<~~>
Woah there. ~~ is a good comparator and all, but it's not the right
one here. ~~ compares an object and a pattern to see if they match.
Damian Conway wrote:
BTW, I am *sorely* tempted to suggest the following implementation
instead:
which would produce:
uniq ; #
uniq { lc } ; # 'a'|'A', 'b',
'C'|'c', 'd'
uniq { abs $^value } 42, 23, -23, 23, 42;# 42, 23|-23
But I'd
Hi,
Damian Conway wrote:
> BTW, I am *sorely* tempted to suggest the following implementation
> instead:
[...]
> which would produce:
>
> uniq ; #
>
> uniq { lc } ; # 'a'|'A', 'b',
> 'C'|'c', 'd'
>
> uniq { abs $^value } 42, 23, -23,
Ingo Blechschmidt wrote:
Is it intentional that there's no uniq in the current S29[1] draft?
See [2] for Damian saying that uniq is probably in.
It still probably is.
I wondered what uniq's default comparator should be, =:=?
&infix:<~~>
Should it be possible to give an own comparator block, simil
On 5/19/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote:
> I read this as that uniq should behave like Unix's uniq(1), i.e.
> removing only successive duplicates, e.g.:
> uniq [3,3,3,4,3] => [3,4,3] # what I meant
> uniq [3,3,3,4,3] => [3,4] # what you meant
That has been discussed
Ingo Blechschmidt skribis 2005-05-19 21:07 (+0200):
> I read this as that uniq should behave like Unix's uniq(1), i.e.
> removing only successive duplicates, e.g.:
> uniq [3,3,3,4,3] => [3,4,3] # what I meant
> uniq [3,3,3,4,3] => [3,4] # what you meant
Which leads to lots of |so
Hi,
Adriano Ferreira wrote:
> quoting Damian's original mail[1]:
>> uniq - remove duplicates without reordering
> ^^
>
> Would not that mean the original order of the first ocurrence is
> preserved? This is what Ruby Array#uniq does:
>
> [4,1
The former implementation can be shortened:
sub uniq {
my %h;
return grep { ! $h{$_}++ } @_;
}
But realize that none of the proposed solutions (which are based on
hashes for computing the return) is amenable to the extension Ingo
called for with comparator blocks.
Adriano.
quoting Damian's original mail[1]:
> uniq - remove duplicates without reordering
^^
Would not that mean the original order of the first ocurrence is
preserved? This is what Ruby Array#uniq does:
[4,1,2,4,2,3,5].uniq => [ 4, 1, 2, 3, 5]
The b
Hi,
Mark Overmeer wrote:
> * Ingo Blechschmidt ([EMAIL PROTECTED]) [050519 16:52]:
>> Should it be possible to give an own comparator block, similar as
>> with grep? E.g.
>> uniq ; #
>>
>> uniq:{ abs $^a == abs $^b } 42, 23, -23, 23, 42
>> # 42, 23, 42
>
> 'uniq' d
* Ingo Blechschmidt ([EMAIL PROTECTED]) [050519 16:52]:
> Should it be possible to give an own comparator block, similar as with
> grep? E.g.
> uniq ; #
>
> uniq:{ abs $^a == abs $^b } 42, 23, -23, 23, 42
> # 42, 23, 42
'uniq' differs from 'sort' because there is no
Hi,
Rod Adams wrote:
>>I wondered what uniq's default comparator should be, =:=?
> I'd have gone with ~~
Even better. :)
--Ingo
--
Linux, the choice of a GNU | Row, row, row your bits, gently down the
generation on a dual AMD | stream...
Athlon!|
Ingo Blechschmidt wrote:
Hi,
three quick questions:
Since Aaron is still getting up to speed, I'll take a stab at these.
Is it intentional that there's no uniq in the current S29[1] draft?
See [2] for Damian saying that uniq is probably in.
Just hasn't been entered.
I wondered what uniq's def
Hi,
three quick questions:
Is it intentional that there's no uniq in the current S29[1] draft?
See [2] for Damian saying that uniq is probably in.
I wondered what uniq's default comparator should be, =:=?
Should it be possible to give an own comparator block, similar as with
grep? E.g.
uniq ;
17 matches
Mail list logo