functor - I have this last exercise in Prolog to solve in lessons i do alone and dont know what to do -
i have last problem free lessons take online ,to solve , dont know start cant understand predicate does...
write predicate
replace_var_args (term, values, newterm)true if replaces terms oftermvariables values list «values». is, 1st variable oftermreplaced 1st term of listvalues, 2nd variable oftermreplaced 2nd term of listvalues, on until listvaluesbecomes empty. finally, returns new termnewterm. use built-in predicatesfunctor/3,=../2,var/1,nanvar/1, etc. examples of goals,a) ?- replace_var_args(father(yannis,x), [anna], newterm). newterm = father(yannis,anna), b) ?- replace_var_args(f(a,x,g(b), y,h(a,z)), [b,c], newterm). newterm = f(a,b,g(b),c,h(a,z)), c) ?- replace_var_args(f(a,x,f(b),y,h(a,z)), [b,c,d], newterm). newterm = f(a,b,g(b),c,h(a,d)). d) ?- replace_var_args(t(x, y, z,a,f(z,b)), [1,2,3], newterm). newterm = t(1,2,3,a,f(z,b)).
Comments
Post a Comment