Some Mathematica functions call explicitly for two objects, not more or less; however, I want to run these functions over more than three objects.
For example, let's say I collect several genes of interest, and save them in FASTA format. I import them from one file; now I have a variable that contains a list of several proteins; i.e., I have a list of i elements, where each element a_i is a string:
list = ImportString[
What I would like to do is find the longest common subsequences of all these strings. The perfect candidate for this seems to be Mathematica's LongestCommonSubsequence function. However, this function expects exactly two objects, in this format:
LongestCommonSubsequence[String 1, String 2]
If I just write:
The code fails to work. I then thought I could write a function that takes two strings and compares them and map it over:
csub[x___String, y___String] = LongestCommonSequence[x, y]
csub /@ list
However, this doesn't work because Map works it's way over each and every element separately. Obviously this fails because my function is expecting two objects, but only gets one from Map.
Is there a nice way to iterate over my list of strings and find the longest common sequence in all of them rather than having to call a function for each two individually, and then compare those in pairs, etc.?
Maybe something as in
For i in list
string = LongestCommonSequence[i, i+]