Count how many different values a list takes in Mathematica

后端 未结 4 1566
梦谈多话
梦谈多话 2021-02-08 02:45

I would like to get the number of different values found in a List.

For example:

The output for the List a={1,2,3,4,5} would be 5 whereas it would b

4条回答
  •  暖寄归人
    2021-02-08 03:05

    Length[DeleteDuplicates[a]]
    

    would do the trick. Depending on what else you're going to do, you could use Union or Tally instead of DeleteDuplicates.

提交回复
热议问题