In sicstus prolog, there's a predicate:
Pred is supposed to take just one argument -
List element. How can I pass a 2-argument predicate, with first argument defined? In other languages it would be written as:
Best How To :
maplist(P_1, Xs) will call
call(P_1, X) for each element of
Xs. The built-in predicate
call/2 adds one further argument to
P_1 and then calls this with
call/1. To indicate that a further argument is needed, it is very helpful to use a name like
P_1 meaning "one extra argument is needed".
So if you have already a predicate of arity 2, say,
(=)/2, you will pass
=(2) to maplist:
?- maplist(=(2), Xs).
Xs =  ;
Xs =  ;
Xs = [2,2] ...
Since the definition in SICStus' library is unfortunately, incorrect, rather use the following definition:
maplist(P_1, Xs) :-
maplist_i([E|Es], P_1) :-
See this answer for more.
Just a nice further example about lists of lists.
?- Xss = [[A],[B,C]], maplist(maplist(=(E)), Xss).
Xss = [[E], [E, E]],
A = B, B = C, C = E.