Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'If same element exists in a list, gives 0.' topicStudent Support Forum > General > Archives > "If same element exists in a list, gives 0."

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
02/20/13 1:34pm

In[1]:= f[v_]:=If[Union[v]==v,1,0];

In[2]:= f[{1,3,5,5,9}]
Out[2]= 0

In[3]:= f[{1,3,3,9,9}]
Out[3]= 0

In[4]:= f[{1,5,5,5,9}]
Out[4]= 0

In[5]:= f[{1,3,5,7,9}]
Out[5]= 1

URL: ,

Subject (listing for 'If same element exists in a list, gives 0.')
Author Date Posted
If same element exists in a list, gives 0. simple 02/19/13 9:31pm
Re: If same element exists in a list, gives 0. Bill Simpson 02/20/13 1:34pm
Re: Re: If same element exists in a list, gives... yehuda 02/20/13 3:25pm
Re: If same element exists in a list, gives 0. Bill Simpson 02/20/13 4:08pm
Re: If same element exists in a list, gives 0. yehuda 02/21/13 3:08pm
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic