Skip to content

Monotonic equivalent of findall(X, (member(X, [a(1), b(2), c(3)]), X \= a(_)), Xs). #2539

Closed Answered by bakaq
jjtolton asked this question in Q&A
Discussion options

You must be logged in to vote

What you would need here is a predicate pattern_match_t/3 to be used with tfilter/3, but I don't think general pattern matching is monotonic.

This is the best I could come up, and maybe it's enough for your uses:

?- [user].
:- use_module(library(reif)).

% T = true if either the functor indicator or arity are different
different_functor_t(A, B, T) :-
    functor(A, AFunctor, AArity),
    functor(B, BFunctor, BArity),
    ';'(dif(AFunctor, BFunctor), dif(AArity, BArity), T).

?- tfilter(different_functor_t(a(_)), [a(1), b(2), c(3)], Xs).
   Xs = [b(2),c(3)].

Replies: 5 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@jjtolton
Comment options

@UWN
Comment options

Answer selected by jjtolton
Comment options

You must be logged in to vote
1 reply
@jjtolton
Comment options

Comment options

You must be logged in to vote
1 reply
@jjtolton
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants