Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

How to select unique elements in a list?

  • To: mathgroup at
  • Subject: [mg7949] How to select unique elements in a list?
  • From: "C. Woll" <carlw at>
  • Date: Fri, 25 Jul 1997 02:40:25 -0400
  • Sender: owner-wri-mathgroup at

Hi all,

First, let me say that Union does not do what I'm looking for! I am
interested in a function which returns the unique elements from a list.
Let's call the function Distinct. Then, I want


to return


Of course, I can write a function to do this, but I am hoping someone can
do a better job them my feeble attempt. So, my best functional solution so
far is,


However, this solution is very slow. For example, with


it takes approximately 27 seconds to evaluate Distinct[test] on an SGI
system. This is slow when compared to .01 seconds to evaluate Union[test]!

It's likely that the way to go is to use a procedural method instead of a
functional method.

At any rate, can anyone come up with a solution which is competitive in
speed with Union?

Carl Woll

  • Prev by Date: fonts
  • Next by Date: How to select unique elements in a list?
  • Previous by thread: fonts
  • Next by thread: How to select unique elements in a list?