0
我寫了這個C#代碼來獲取一組單詞的每個子序列。F#中的每個子序列?
static IEnumerable<IEnumerable<string>> Subsequences(IEnumerable<string> words)
{
var arr = words as string[] ?? words.ToArray();
int len = arr.Count();
for (int i = 1; i < len; i++)
for (int j = 0; i + j <= len; j++)
yield return arr.Skip(j).Take(i);
}
你會如何在F#中編寫它?