Advertisement
cd62131

q10280621600 subst_functor/2

May 28th, 2023
2,451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.41 KB | None | 0 0
  1. subst_functor(X, X) :- atomic(X).
  2. subst_functor(X, Y) :-
  3.     X =.. [f, ArgX],
  4.     Y =.. [h, ArgY],
  5.     subst_functor_list([ArgX], [ArgY]).
  6. subst_functor(X, Y) :-
  7.     X =.. [g, ArgX1, ArgX2],
  8.     Y =.. [g, ArgY1, ArgY2],
  9.     subst_functor_list([ArgX1, ArgX2], [ArgY1, ArgY2]).
  10. subst_functor_list([], []).
  11. subst_functor_list([H1|T1], [H2|T2]) :-
  12.     subst_functor(H1, H2),
  13.     subst_functor_list(T1, T2).
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement