I need to find the combinations in a list of lists. For example, give the following list,
List = [[1, 2], [1, 2, 3]]
These should be the ou
A twist in @false's approach:
%list_comb( ++LL, -Ess)
list_comb( LL, Ess):-
is_list( LL),
maplist( is_list, LL),
findall( Es, maplist( member, Es, LL), Ess).
Testing:
41 ?- list_comb( [[1,2],[1],[1]], X). X = [[1, 1, 1], [2, 1, 1]]. 42 ?- list_comb( [[1,2],[1],[1,2,3]], X). X = [[1, 1, 1], [1, 1, 2], [1, 1, 3], [2, 1, 1], [2, 1, 2], [2, 1, 3]]. 43 ?- list_comb( [[1,2],[],[1,2,3]], X). X = []. 44 ?- list_comb( [[1,2],t,[1,2,3]], X). false. 45 ?- list_comb( t, X). false.