Student Support Forum: 'If same element exists in a list, gives 0.' topicStudent Support Forum > General > "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 4:08pm Bad programmer! No cookie! In[1]:= f[v_]:=If[Union[v]==v,1,0]; In[2]:= f[{1,3,5,5,9}] Out[2]= 0 In[3]:= f[{9,5,5,3,1}] Out[3]= 0 In[4]:= f[{1,3,5,7,9}] Out[4]= 1 In[5]:= f[{9,7,5,3,1}] Out[5]= 0 In[6]:= f[v_]:=If[Length[Union[v]]==Length[v],1,0]; In[7]:= f[{1,3,5,5,9}] Out[7]= 0 In[8]:= f[{9,5,5,3,1}] Out[8]= 0 In[9]:= f[{1,3,5,7,9}] Out[9]= 1 In[10]:= f[{9,7,5,3,1}] Out[10]= 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