I’m using: SWI-Prolog version 8.0.3
I want the code to to show the fact1
But what I’m getting is false
My code looks like this:
% -*- Mode: Prolog -*-
:- use_module(library(apply)).
byte_nonzero(B, R) :-
B > 0, R = true.
byte_nonzero_acc(B, Acc0, Acc) :-
Acc0, byte_nonzero(B, Acc).
bytes_nonzero(B, R) :-
foldl(byte_nonzero_acc, B, true, R).
rule_nonzero(_, B, _, R) :-
bytes_nonzero(B, R).
some_fact(0, [10, 20, 30], "fact1").
some_fact(10, [10, 0, 30], "fact2").
some_relation(rule, A) :-
some_fact(A, B, C),
call(rule, A, B, C, true).
So if I load this test.pl
in the toplevel with
?- consult('test.pl').
true.
?- some_fact(A, B, C), call(rule_nonzero, A, B, C, true).
A = 0,
B = [10, 20, 30].
C = "fact1".
?- some_relation(rule_nonzero, A).
false.
Why it shows false.
while the relation is essentially the same as the query I typed, and it worked (some_fact(A, B, C), call(rule_nonzero, A, B, C, true).
).