Recently I noticed that following query for maplist/N fails with N = 0,1 :
?- predicate_property(maplist, meta_predicate(I)).
%@ false.
?- predicate_property(maplist( = ), meta_predicate(I)).
%@ false.
Is it for N=0,1 a bug or normal ? As maplist/N seems not a meta predicate
for N = 0,1, I had to add a local rule the maplist/N is a meta predicate
for N = 0, 1, because of a reason below.
Of course, for N >= 2, maplist/N are meta predicates:
?- predicate_property(maplist(=, []), meta_predicate(I)).
%@ I = maplist(1, ?).
?- predicate_property(maplist(=, [], []), meta_predicate(I)).
%@ I = maplist(2, ?, ?).
?- predicate_property(maplist(=, [], [], []), meta_predicate(I)).
%@ I = maplist(3, ?, ?, ?).
BTW, I have a term_expansion (pack/pac) for handling
emacs buffer region. An example among many others is this:
handle([trim, sort, lines]) --> region,
split,
remove([]),
maplist(phrase(wl("[\s\t]*"))),
sort,
maplist(pred([L, [L,"\n"]])),
overwrite.
in which maplist/1 appears in the DCG clause body.
If query
predicate_property(maplist(phrase(wl("[\s\t]*"))), meta_predicate(I))
would return I = maplist(0), then the term_expansion expands the above DCG rule
like this:
handle([trim,sort,lines],A1,A2):-(true,A3=A1),region(A3,A4),split(A4,A5),
remove([],A5,A6),maplist(‘pac#8’,A6,A7),sort(A7,A8),
maplist(‘pac#9’,A8,A9),overwrite(A9,A2) .
‘nt#1’([9|A],B):-‘nt#1’(A,B) .
‘nt#1’([32|A],B):-‘nt#1’(A,B) .
‘nt#1’(A,A) .
‘pac#8’(A,B):-‘nt#1’(A,B) .
‘pac#9’(A,[A,"\n"]) .
In fact, this codes is an output of the term expansion
after adding an ad hoc rule to the term_expansion
to tell that maplist/1 is a meta_predicate.
Kuniaki Mukai