It’s “obvious” if you’ve been exposed to currying, although it only looks like currying; under the covers, something else is going on.
One of the things that trips up people learning Prolog is that terms and predicates look the same – this is very convenient for things like “macros” (
term_expansion and friends), but it can lead to confusion.
Whenever a predicate is defined, you can think of it as simultaneously defining some
call facts that can look up a term and call the predicate that “looks like” the term. For example, defining
pred(A, B) :- ...
can be thought of as also defining
call(pred, A, B) :- pred(A, B).
call(pred(A), B) :- pred(A, B).
call(pred(A, B)) :- pred(A, B).
So, when you invoke
include(pred(something), [a, list, of, values]), this ends up calling
pred(something, of) ,
This gets more interesting with meta-predicates like
maplist. For example, these are valid calls:
maplist(pred, [1,2,3,4], [20,30,40,50]). % pred(1,20), pred(2,30), pred(3,40), pred(4,50)
maplist(pred(1), [20,30,40,50]). % pred(1,20), pred(1,30), pred(1,40), pred(1,50)