问题
Very simple question: I know there are plenty of ways to split an atom, eg 'example atom' on some delimiter, eg ' ' -> ['example', 'atom'] but is there a way to split up every character? Eg ['e', 'x', 'a', ... 'o', 'm']. I've tried
atomic_list_concat(List, '', Atom),
but that generates the error
ERROR: atomic_list_concat/3: Domain error: `non_empty_atom' expected, found `'
What would you recommend?
回答1:
Do you want something like this?
http://www.swi-prolog.org/pldoc/doc_for?object=atom_chars/2
?- atom_chars(hello, X).
X = [h, e, l, l, o].
来源:https://stackoverflow.com/questions/31478457/swi-prolog-splitting-text-atom-into-list-of-characters