Re: All componens different
- To: mathgroup at smc.vnet.net
 - Subject: [mg112006] Re: All componens different
 - From: Bill Rowe <readnews at sbcglobal.net>
 - Date: Tue, 24 Aug 2010 06:14:01 -0400 (EDT)
 
On 8/23/10 at 2:51 AM, weh at snafu.de (Dr. Wolfgang Hintze) wrote:
>Given a list v of natural numbers I'm looking for a function d[v_]
>that returns True if all components are different and False
>otherwise.
>One solution is
>d1[v_] := ! Or @@ Flatten[Table[v[[i]] == v[[k]], {i, 1, Length[v]},
>{k, i + 1, Length[v]}]]
>Can you find more efficient (and elegant) solutions?
The following should be more efficient:
d1[v_]:=Length[Union@v]==1