How to use maplist on inner term?
Assuming the KB is:
gate(not(o), i).
gate(not(i), o).
gate(and(o, i), o).
gate(and(i, o), o).
gate(and(B, B), B).
bits([i,o,o,i,i]).
The following is not working:
?- bits(BITS), maplist(gate(not(X), Y), BITS, ANS)
How can I map over the list so that:
[i,o,o,i,i]
-> [not(i), not(o), not(o), not(i), not(i)]
->[o,i,i,o,o]
This is to be done on any list length:
:- bits([A,B,C,D,E]), gate(not(A), Anew), gate(not(B), Bnew), gate(not(C), Cnew), gate(not(D), Dnew), gate(not(E), Enew), ANS = [Anew, Bnew, Cnew, Dnew, Enew].
So that the answer would be: ANS = [o, i, i, o, o]