Toggle navigation
?
users online
Logout
Open hangout
Open chat for current file
:- use_module(library(clpfd)). % Works but returns all possible results, which is infinte and useless. members([], _). members([X|Xs], List) :- member(X,List), members(Xs, List). % Restricts the results to only the ones with a certain length, more useful. Terminates. Good stuff. membersWithLength(Members, List, Bound) :- L = Bound, length(Members, L), members(Members, List). % Kind of works. Finds the right results (lists with length less than Bound). % But it loops continuously searching for more results even after it has found the correct ones. membersLessThan(Members, List, Bound) :- L in 0..Bound, % I also tried L #=< Bound here. Same problem. membersWithLength(Members, List, L). % Works. Finds all the lists with length less than or equal to Bound. Terminates. Good stuff. % But it disapponted me that I could not figure out how to use clp to bound the search. membersLessThan_(Members, List, Bound) :- numlist(0,Bound,ZeroToBound), member(L, ZeroToBound), membersWithLength(Members, List, L).