I am trying to check if a string is a working call that can be executed. To do this I parse the string, get the first word, and if it matches a database of predefined functions, it should succeed. Q has the string, A will be used later, not now. Example of string is: append a and b.
is_uni(Q, A):-
split_string(Q, " ", ",", [X|Y]),
uni_db(Z),
member(X, Z).
uni_db([
append,
member,
append1
]).
You need to use atom_codes/2
predicate to convert stings to atoms, in example you need to convert "append"
to append
in order to work.
is_uni(Q,A):-
split_string(Q, " ", ",", [X|Y]),
atom_codes(W,X),
uni_db(Z),
member(W, Z).
Example:
?- is_uni("append a and b",A).
true ;
false.