How to define a
as a integer/float number ?
I want to find the results of a+b+c+d=10
where a,b,c,d
is integer and >=0
.
How to define a
as a integer/float number ?
I want to find the results of a+b+c+d=10
where a,b,c,d
is integer and >=0
.
Here is GNU-Prolog piece of code with constraint solving over finite domains :
Ctrl + D
As you can see, it solves problem of big ranges like 0-9999999
P.S. Thanks for Przemysław Kobylański for his blog with clear, very nice Prolog examples, where I've found inspiring examples.
P.P.S. When playing with finite domains, you might like to use fd_set_vector_max/1 . In above case it's not needed, but depending on constraint might be usefull - more details when Gnu-Prolog operates on ranges, when on vectors of possible values, can be found at manual "Finite domain solver and built-in predicates - Introduction"
Here is a simple, modern, pure Prolog, non-CLP-library solution:
with SWI-Prolog you can use CLP(FD) library