⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 permutation.logic

📁 国外的一套开源CRM
💻 LOGIC
字号:
/*
Demonstration of creating permutations.
Usage: permutation(InList, OutList)
OutList is a permutation of InList.

Try the query:
    permutation(["get kids", "mail package", "buy milk"], toDo)
which should produce the result:
    toDo = [get kids, mail package, buy milk]
    toDo = [get kids, buy milk, mail package]
    toDo = [mail package, get kids, buy milk]
    toDo = [mail package, buy milk, get kids]
    toDo = [buy milk, get kids, mail package]
    toDo = [buy milk, mail package, get kids]
    no more results
*/
select(X, [X | Rest], Rest);
select(X, [Y | Rest1], [Y | Rest2]) :- select(X, Rest1, Rest2);
permutation(InList, [H | OutRest]) :- 
    select(H, InList, InOther), 
    permutation(InOther, OutRest);
permutation([], []);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -