From c08e99a77c37737d33e253b8b280f687b6ee1354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Tue, 7 Dec 2010 17:50:51 +0000 Subject: [PATCH] fix mapnodes/2 (obs from Ingo Molnar). --- docs/yap.tex | 9 ++++----- library/maplist.yap | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/yap.tex b/docs/yap.tex index 55be4eec5..6e09202af 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -9553,10 +9553,9 @@ plus_if_pos(X,Y,Z) :- Y > 0, Z is X + Y. vars(X, Y, [X|Y]) :- var(X), !. vars(_, Y, Y). trans(TermIn, TermOut) :- - (compound(TermIn) ; atom(TermIn)), + nonvar(TermIn), TermIn =.. [p|Args], - TermOut =..[q|Args], - !. + TermOut =..[q|Args], !. trans(X,X). %success @@ -9567,8 +9566,8 @@ selectlist(<(0), [-1,0,1], [1]). convlist(plus_if_pos(1), [-1,0,1], [2]). sumlist(plus, [1,2,3,4], 1, 11). mapargs(number_atom,s(1,2,3), s('1','2','3')). -sumargs(vars, s(1,X,2,Y), [], [Y,X]). -mapnodes(trans, p(a,p(b,a),c), q(a,q(b,a),c)). +sumargs(vars, s(1,X,2,Y), [], [Y,X]).m +apnodes(trans, p(a,p(b,a),c), q(a,q(b,a),c)). checknodes(\==(T), p(X,p(Y,X),Z)). sumnodes(vars, [c(X), p(X,Y), q(Y)], [], [Y,Y,X,X]). % another one diff --git a/library/maplist.yap b/library/maplist.yap index f0de33566..4ba4a08af 100644 --- a/library/maplist.yap +++ b/library/maplist.yap @@ -206,7 +206,7 @@ sumargs_args(Pred, Term, A1, A3, N) :- sumargs_args(Pred, Term, A2, A3, N1). mapnodes(Pred, TermIn, TermOut) :- - (atomic(TermIn); var(TermOut)), !, + (atomic(TermIn); var(TermIn)), !, call(Pred, TermIn, TermOut). mapnodes(Pred, TermIn, TermOut) :- call(Pred, TermIn, Temp),