i'm newbie prolog , trying understand prolog code.
next_truth_value([0|r],[1|r]). next_truth_value([1|r],[0|s]) :- next_truth_value(r,s). through research found predicate contains 2 lists. if query answer this...
?- next_truth_value([0,0], next). next = [1,0] please explain code, i'm totally helpless understanding meant. thank you.
this code calculating next binary number (reversed). if have binary number 00, next binary number 01 (which represented [1,0]). predicate change 0 one, if there 1 (like in binary number 01), have further in list find 0 turn one. code way not work list [1,1], return false.
you use same code find previous binary number. if use predicate this: next_truth_value(prev,[1,0])., result [0,0].
Comments
Post a Comment