How i could create a predicate in order to enlist all possible combinations of binary numbers of length N?
Example -> If length N = 3 then the output is
L = [0,0,0]
L = [0,0,1]
L = [0,1,0]
L = [0,1,1]
L = [1,0,0]
L = [1,0,1]
L = [1,1,0]
L = [1,1,1]
false
binary_list(0,[]).
binary_list(N,[X|Xs]) :-
N > 0,
member(X,[0,1]),
N1 is N-1,
binary_list(N1,Xs).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.