My Prolog code is not working
maxdis(A, B, C, D) :-
( abs(A - B) >= abs(A - C) ->
D is abs(A - B),
write(D),
( abs(B - C) >= abs(A - B) ->
D is abs(B - C),
write(D)
; write(D)
)
; D is abs(A - C),
write(D)
).
result:
maxdis(0,12,-8,X).
12
no
Expected result: 20
Aucun commentaire:
Enregistrer un commentaire