% Predicates in lambda Prolog that define some of `higher-order' % mapping operations. module preds. import List. type mappred (A -> B -> o) -> list A -> list B -> o. type forevery, forsome (A -> o) -> list A -> o. type sublist (A -> o) -> list A -> list A -> o. % Relates a binary predicate P and two lists if corresponding elements % of the two lists are P-related. mappred P nil nil. mappred P (X :: L) (Y :: K) :- P X Y, mappred P L K. % Relates a predicate and a list if every element in the list satisfies P. forevery P nil. forevery P (X :: L) :- P X, forevery P L. % Relates a predicate and a list if some element in the list satisfies P. forsome P (X :: L) :- P X ; forsome P L. % Relates a predicate with two lists if the second is a subkist of the % first, all of whose elements are members of the first list. sublist P (X::L) (X::K) :- P X, sublist P L K. sublist P (X::L) K :- sublist P L K. sublist P nil nil.