MathGroup Archive 2010

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

Search the Archive

Re: All componens different

  • To: mathgroup at smc.vnet.net
  • Subject: [mg112001] Re: All componens different
  • From: Helen Read <hpr at together.net>
  • Date: Tue, 24 Aug 2010 06:13:07 -0400 (EDT)
  • References: <i4t5qb$g2q$1@smc.vnet.net>
  • Reply-to: read at cems.uvm.edu

On 8/23/2010 2:51 AM, 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?
>
> Regards,
> Wolfgang

d[v_] := Length[Union[v]] == Length[v]

--
Helen Read
University of Vermont


  • Prev by Date: Re: All componens different
  • Next by Date: Solve[Function] 2 quick questions
  • Previous by thread: Re: All componens different
  • Next by thread: Re: All componens different