Student Support Forum: 'Functions calling for exactly Two Arguments' topicStudent Support Forum > General > "Functions calling for exactly Two Arguments"

 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic
 Author Comment/Response jf 07/06/13 6:49pm To run a function of multiple arguments over many sets of arguments, use Thread or MapThread. Schematic example: Make a list of all possible pairs. In[1]:= ol = Outer[List, {a, b, c}, {a, b, c}] Get rid of the extra level of nesting. In[2]:= olf = Flatten[ol, 1] Drop the cases in which the two elements are the same. In[3]:= olfd = DeleteCases[olf, {q_, q_}] Drop the redundant cases in which the two elements are in opposite order. In[4]:= dd = DeleteDuplicates[Map[Sort, olfd ]] // Transpose Out[4]= {{a, a, b}, {b, c, c}} Now run the function over the two lists. In[5]:= MapThread[LongestCommonSubsequence, dd] Attachment: 547156.nb, URL: ,

 Subject (listing for 'Functions calling for exactly Two Arguments') Author Date Posted Functions calling for exactly Two Arguments Michael Senter 07/05/13 7:50pm Re: Functions calling for exactly Two Arguments jf 07/06/13 6:49pm Re: Re: Functions calling for exactly Two Argum... Peter Pein 07/07/13 06:21am
 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic