What does "nub" stand for? (This is the first I've heard of it.)
Hmm, maybe that's not such a great explanation. I wonder who can come up with the best acronym? My contribution is
"Note Unique Bits"
"no duplicates" (or "no doubles") although that's no acronym Christian
Sorry, meant to send this to the list, not Christian... ---- Original Message: From: Alistair Bayley Sent: Wednesday 27 Nov 2002 20:32 Subject: Re: nub Wouldn't this have been better called "unique"? (analogous to the Unix program "uniq"). I was looking for a "unique" in the GHC Data.List library a few days ago, and didn't see one, so I wrote my own (not realising that was what "nub" did). ---- Original Message: From: Christian Maeder Sent: Tuesday 26 Nov 2002 17:51 Subject: nub
What does "nub" stand for? (This is the first I've heard of it.)
Hmm, maybe that's not such a great explanation. I wonder who can come up with the best acronym? My contribution is
"Note Unique Bits"
"no duplicates" (or "no doubles") although that's no acronym Christian
On Thu, Nov 28, 2002 at 10:21:53PM +0000, Alistair Bayley wrote:
Wouldn't this have been better called "unique"? (analogous to the Unix program "uniq"). I was looking for a "unique" in the GHC Data.List library a few days ago, and didn't see one, so I wrote my own (not realising that was what "nub" did).
No, Unix uniq makes only a single pass. uniq = map head . group (A much tidier definition than the one I gave a few days ago :-) By contrast, "nub" removes duplicate elements from the list no matter where they are. I think both functions are useful. If I understand it right, uniq can evaluate its argument list lazily, while nub cannot. There's no real need to put uniq in the standard library, though. Hmm, but with that said, I don't think I disagree with you. Renaming "nub" to "unique" makes it clear that it is similar, but not identical to what Unix "uniq" does. Richard Braakman
Richard Braakman <dark@xs4all.nl> writes:
On Thu, Nov 28, 2002 at 10:21:53PM +0000, Alistair Bayley wrote:
Wouldn't this have been better called "unique"? (analogous to the Unix program "uniq"). I was looking for a "unique" in the GHC Data.List library a few days ago, and didn't see one, so I wrote my own (not realising that was what "nub" did).
BTDT.
No, Unix uniq makes only a single pass. uniq = map head . group
Hmm, but with that said, I don't think I disagree with you. Renaming "nub" to "unique" makes it clear that it is similar, but not identical to what Unix "uniq" does.
And of course the traditional Unix idiom for "nub" is 'sort | uniq' (or (uniq . sort) if you prefer) -kzm -- If I haven't seen further, it is by standing in the footprints of giants
participants (4)
-
Alistair Bayley -
Christian Maeder -
ketil@ii.uib.no -
Richard Braakman