Subversion Repositories programming

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
107 ira 1
/* pair2.pl -- pairs of digits WITHOUT replacement */
2
 
3
pair(L) :- L = [X,Y],
4
           free_digit(X,L),
5
           free_digit(Y,L).
6
 
7
free_digit(Dig,UsedList) :- var(Dig),
8
                            digit(X),
9
                            not_in(X,UsedList),
10
                            Dig = X.
11
 
12
free_digit(Dig,_) :- nonvar(Dig).
13
 
14
digit(0).
15
digit(1).
16
digit(2).
17
 
18
not_in(_,[]).
19
not_in(D,[H|T]) :- var(H), not_in(D,T).
20
not_in(D,[H|T]) :- nonvar(H), D \= H, not_in(D,T).
21