Here's one (crude) solution!
start(A, B, C, D) :-
manipulate(A, B, C, D), !,
start(_, _, _, _) :-
manipulate(A, B, C, D) :-
Note: both admitPatient and (P,oncology) would each be contained in some variable (ALL terms preferably). Since i haven't got terms as variables i'll put the query in manually as follows:
start('z', 'admitPatient', '1', '(P,oncology)').
This writes the modified term to filename.pl.
Which contains the new predicate:
Then to use the new predicate could use:
Is crude but is a start and it works!
To do it dynamically I guess you would need to add this line:
:- dynamic admitPatient/2.
The infix operator '=..' (pronounced "univ") can be used either to
decompose a term into a list containing its functor and arguments or
else to construct a term from such a list.
To extract the term 'admitPatient' perhaps a call similar to:
?- admitPatient(P, oncology) =.. [H|B] .
P = _G404
H = admitPatient
B = [_G404, oncology] ;
Variable H (inserted at paramater B in my 'static' code above for example) can then be manipulated; likewise Variable B (inserted at paramater D above).
:excl: Of course there's a better way as i'm just a novice. :unsure: