Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Identical elements

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88431] Re: [mg88374] Identical elements
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Mon, 5 May 2008 06:13:32 -0400 (EDT)
  • References: <200805031017.GAA04030@smc.vnet.net>

On 3 May 2008, at 19:17, KFUPM wrote:

> Dear All
>
> I have a list  and i need to test whether all the elements in the list
> are identical or no. What is the efficient way to do that? The output
> should be true if all elements are the same and False otherwise. One
> line command is preferred if possible.
>
> Your help is highly appreciated.
>
> Regards,
>
> HMQ
>

Do you really mean identical and not euqal? This is an important  
distinction in Mathematica! Assuming that you do:

ls = {1, 1, a, 1};

SameQ @@ ls
  False

  ls = {a, a, a, a};

SameQ @@ ls
True

Andrzej Kozlowski


  • Prev by Date: 32-bit front-end on 64-bit machine
  • Next by Date: Re: Identical elements
  • Previous by thread: Identical elements
  • Next by thread: Re: Identical elements