Convlist/3 with additional argument(s) example

For an example of convlist/3 when the goal needs an additional argument see this example by Peter

use_module(library(apply)).

find_in_term(Functor, Within, FoundArgs) :-
    Within =.. [Functor|FoundArgs].
find_in_term(Functor, Within, FoundArgs) :-
    Within =.. [_|WithinArgs],
    convlist(find_in_term(Functor), WithinArgs, FoundArgsList),
    member(FoundArgs, FoundArgsList).

This is posted so that it is easier to find.

I don’t have the time now to make further examples but the example by Peter was enough to get me unstuck.

Note that in the referenced topic Peter gives a revised version of the code that does not use convlist/3; as your mileage may very (more readable code, faster code, etc.) you will have to decide.

1 Like