%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Miscellaneous Functions Needed by Expert System Shells % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% member(Element,[Element|List]). member(Element,[_|List]):-member(Element,List). append([],List,List). append([E1|L1],L2,[E1|L3]):-append(L1,L2,L3). replace([OF|OM],OF,NI,[NI|OM]). replace([OF|OM],OI,NI,[OF|NL]):-replace(OM,OI,NI,NL). remove([OF|OM],OF,OM). remove([OF|OM],OI,[OF|NL]):-remove(OM,OI,NL). insert(OldList,Item,NewList):- append(LeftPart,RightPart,OldList), append(LeftPart,[Item|RightPart],NewList). % Satisfy goal at most once. % :-op(900,fx,once). once Goal:-Goal,!. % Procedures for console output using a C++-like insertion % operator. (A simpler implementation can be found in file str.pro.) % % % Sample uses: % % ?-human(X),sOut<<"The name "<