I am using read() to take in user input. I planned that my program would accept input in the form of
a,b,c,d,e
and then I would convert that into a list of the elements. But doing a test in prolog i got this
26 ?- read(X).
|: abc,def,ghi,jkl.
X = (abc, def, ghi, jkl).
I am not sure, but is this returning a structure? What can I do to convert this into a list?
(abc, def, ghi, jkl) is a term with functor ‘,’ and arity 2. You can use term inspection predicates like (=..)/2, functor/3, arg/3 etc. to decompose it, or try write_canonical/1:
To convert such tuples to lists, you can use a DCG:
Example: