Skip to content

clpz and label #1937

Answered by triska
mvolkmann asked this question in Q&A
Jul 31, 2023 · 2 comments · 6 replies
Discussion options

You must be logged in to vote

As an example, so that you can remove side-effects from the program, we can write:

demo(A*B*C = -6) :-
        Vs = [A,B,C],
        Vs ins -6..6,
        A*B*C #= -6,
        label(Vs).

Yielding:

?- demo(T).
   T = (-6* -1* -1= -6)
;  T = (-6*1*1= -6)
;  T = (-3* -2* -1= -6)
;  T = (-3* -1* -2= -6)
;  ... .

Such answers can be easily tested and reasoned about. Further, programs without side-effects can be run with any execution strategy, a major attraction of Prolog.

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@mvolkmann
Comment options

@triska
Comment options

Answer selected by mvolkmann
@mvolkmann
Comment options

@triska
Comment options

@mvolkmann
Comment options

@UWN
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants