2

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?

Dan Lowe
  • 51,713
  • 20
  • 123
  • 112
EmmetOT
  • 552
  • 1
  • 7
  • 23

1 Answers1

11

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].
BretC
  • 4,141
  • 13
  • 22
  • Perfect! Obviously I'm just terrible at googling. Thanks. – EmmetOT Jul 17 '15 at 14:50
  • @Boris - I'm well aware. I must have just missed it. I'm still new to prolog, and sometimes it can be difficult to know what you're looking for when you're unfamiliar with the terminology. – EmmetOT Jul 18 '15 at 14:59
  • @EmmetOT please remember to mark the answer as accepted if this is the solution that you were looking for. – Yasel Jul 18 '15 at 18:41