diff options
-rw-r--r-- | stdlib.pl | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -230,6 +230,10 @@ atomic(T) :- atom(T) ; integer(T) ; float(T). % type assertions (throws an error if false) +is_atom(T) :- atom(T), ! ; type_error(atom, T). + +is_atom_or_var(T) :- (atom(T) ; var(T)), ! ; type_error(atom, T). + is_callable(T) :- callable(T), ! ; type_error(callable, T). is_nonvar(T) :- nonvar(T), ! ; instantiation_error. @@ -376,4 +380,29 @@ sort(Ls0, Ls) :- !, append(Lefts, [A|Rights], Ls1), sort(Ls1, Ls). -sort(Ls, Ls).
\ No newline at end of file +sort(Ls, Ls). + +% Atomic term processing + +atom_concat(A1, A2, A3) :- + is_atom_or_var(A1), + is_atom_or_var(A2), + is_atom_or_var(A3), + atom(A1), atom(A2), + !, + atom_codes(A1, Codes1), + atom_codes(A2, Codes2), + append(Codes1, Codes2, Codes), + atom_codes(A3, Codes). +atom_concat(A1, A2, A3) :- + is_atom_or_var(A1), + is_atom_or_var(A2), + is_atom_or_var(A3), + atom(A3), + !, + atom_codes(A3, Codes), + append(Codes1, Codes2, Codes), + atom_codes(A1, Codes1), + atom_codes(A2, Codes2). +atom_concat(A1, A2, A3) :- + instantiation_error.
\ No newline at end of file |