%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Miscellaneous List Processing Predicates. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Predicates For Manipulating Lists % % % member(E,L) succeeds if E is a member of list L. % member(X,[X|_]). member(X,[_|T]):- member(X,T). % % append(List1,List2,List3) succeeds if the result of combining % List1 and List2 is List3. % append([],List,List). append([First|More],List,[First|Rest]):- append(More,List,Rest). % % insert(Item,List1,List2) succeeds if the result of inserting Item % into any position in List1 yields List2. % insert(Item,List1,List2):- append(Lista,Listb,List1), append(Lista,[Item|Listb],List2). % % concat(ListOfLists,List) succeeds if the result of concatenating all % of the lists in ListOfLists is List. % concat([],[]). concat([List|Lists],BigList):- concat(Lists,List2), append(List,List2,BigList).