0
我该如何在SML中实现这个功能?是否有可能将内部for循环更改为递归内部函数?在sml中实现next_permutation?
void RecursivePermute(char str[], int k) {
int j;
// Base-case: All fixed, so print str.
if (k == strlen(str))
printf("%s\n", str);
else {
// Try each letter in spot j.
for (j=k; j<strlen(str); j++) {
// Place next letter in spot k.
ExchangeCharacters(str, k, j);
// Print all with spot k fixed.
RecursivePermute(str, k+1);
// Put the old char back.
ExchangeCharacters(str, j, k);
}
}
}