| PROL |
![]() |
| An
Embeddable Java Prolog Engine (the current version 1.1.3) |


| @Predicate(Signature = "sort/2",
Template = {"+list,?list"},Reference="True if Sorted can be unified
with a list holding the elements of List, sorted to the standard
order of terms") @Determined public static final boolean predicateSORT(final Goal goal, final TermStruct predicate) { final Term nonsorted = Utils.getTermFromElement(predicate.getElement(0)); final Term sorted = Utils.getTermFromElement(predicate.getElement(1)); final Term[] bufferarray = Utils.listToArray((TermList) nonsorted); Arrays.sort(bufferarray, Utils.TERM_COMPARATOR); final TermList sortedList = Utils.arrayToList(bufferarray); return sorted.Equ(sortedList); } |
| @ProlOperators(Operators = { @ProlOperator(Priority = 700, Type = Operator.OPTYPE_XFX, Name = "is"), @ProlOperator(Priority = 700, Type = Operator.OPTYPE_XFX, Name = "="), @ProlOperator(Priority = 1000, Type = Operator.OPTYPE_XFY, Name = ","), @ProlOperator(Priority = 1050, Type = Operator.OPTYPE_XFY, Name = "->"), .... @ProlOperator(Priority = 300, Type = Operator.OPTYPE_XFX, Name = "mod"), @ProlOperator(Priority = 200, Type = Operator.OPTYPE_FY, Name = "\\"), @ProlOperator(Priority = 200, Type = Operator.OPTYPE_XFX, Name = "**") }) public class ProlCoreLibrary extends ProlAbstractLibrary { ... |
|
final ProlContext context
= new
ProlContext("test",DefaultProlStreamManagerImpl.getInstance()); final ProlConsult consult = new ProlConsult("solution([]). solution([X/Y|Others]):-solution(Others),member(Y,[1,2,3,4,5,6,7,8]),notattack(X/Y,Others). notattack(_,[]). notattack(X/Y,[X1/Y1 | Others]):- Y=\\=Y1, Y1-Y=\\=X1-X, Y1-Y=\\=X-X1, notattack(X/Y,Others). member(Item,[Item|Rest]). member(Item,[First|Rest]):-member(Item,Rest). template([1/Y1,2/Y2,3/Y3,4/Y4,5/Y5,6/Y6,7/Y7,8/Y8]).", context); consult.consult(); final Goal goal = new Goal("template(X),solution(X).", context); int combinatioCounter = 0; while (true) { final Term result = goal.solve(); if (result == null) { break; } Utils.printTermState(result); } |
|
threadRed(P) :- for(_, 0, P), rnd(500, X), rnd(400, Y), lock(gfx),
pencolor(red), dot(X, Y), unlock(gfx), fail. threadGreen(P) :- for(_, 0, P), rnd(500,X), rnd(400, Y), lock(gfx), pencolor(green), dot(X, Y), unlock(gfx), fail. threadBlue(P) :- for(_, 0, P), rnd(500, X), rnd(400, Y), lock(gfx), pencolor(blue), dot(X,Y), unlock(gfx), fail. ?- P = 1000000, time((graphics(500,400), fork([threadRed(P), threadGreen(P), threadBlue(P)]))). |
| 1.1.3 |
|
| 1.1.2 |
|
| 1.1.1 |
|
| 1.0.5 |
|
| 1.0.4 |
|
| 1.0.3 |
|
| 1.0.2 |
|
| 1.0.1 |
|
| 1.0.0a |
|