1:- module(swi_atoms,
2 [ restyle_identifier_ex/3,
3 prefix_atom_suffix/4
4 ]).
atom_codes('_', [Code])
, code_type(Code, prolog_symbol)
. Underscore
(code 95) is a Prolog variable start and identifier continuation
symbol, not a Prolog symbol.
Strips any leading underscore or underscores. Succeeds only for text, including codes, but does not throw.
21restyle_identifier_ex(Style, Text, Atom) :-
22 split_string(Text, "_", "_", Strings),
23 atomic_list_concat(Strings, '_', Text_),
24 restyle_identifier(Style, Text_, Atom).
34prefix_atom_suffix(Prefix, Atom0, Suffix, Atom) :- 35 var(Atom), 36 !, 37 atom_concat(Prefix, Atom0, Atom_), 38 atom_concat(Atom_, Suffix, Atom). 39prefix_atom_suffix(Prefix, Atom0, Suffix, Atom) :- 40 atom_concat(Atom_, Suffix, Atom), 41 atom_concat(Prefix, Atom0, Atom_)