Re: [Haskell-cafe] Bool is not...safe?!

Hello, Dušan!
This is not Prolog, it is a Prolog with CLP extension over integers.
as well as Haskell has a lot of extensions. I mentioned CLP as solver but modern Prologs is not ISO only and has a lot of solvers (CHR, different CLP, FuzzyLogic, Tabulating, etc). Actually CLP(x) in included in most modern implementations. 09.07.2018 10:58, Dušan Kolář wrote:
Hello PY/Paul,
You are using misleading arguments!
This is not Prolog, it is a Prolog with CLP extension over integers.
factorial(0, 1).
factorial(N, F) :-
N #> 0,
N1 #= N - 1,
F #= N * F1,
factorial(N1, F1).
I can call it: factorial(5, X) => X=120.
But also: factorial(X, 120) => X=5.
Pure Prolog is:
factorial(0, 1) :- !.
factorial(N, F) :-
NN is N - 1,
factorial(NN, FF),
F is FF * N.
which is a function, not a relation, as you write.
Dušan Kolář
participants (1)
-
PY