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 of term variables values list «values». is, 1st variable of term replaced 1st term of list values, 2nd variable of term replaced 2nd term of list values , on until list values becomes empty. finally, returns new term newterm. use built-in predicates functor/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

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -