diff options
author | Peter Mikkelsen <peter@pmikkelsen.com> | 2021-07-13 19:58:03 +0000 |
---|---|---|
committer | Peter Mikkelsen <peter@pmikkelsen.com> | 2021-07-13 19:58:03 +0000 |
commit | d4fc86d5988dacfca455cac55aae71ad4fd3bb95 (patch) | |
tree | 99da578ea84983e6e8066802746e88b01181d89a | |
parent | 9fd0e7fc78740ec3a0a1a5e97d571d0f9d02b85a (diff) |
Add atom_concat/3
-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 |