我有一个类似 [apple, orange]
的列表我想将其转换为类似 "apple,orange"
的字符串在序言中。你有什么主意吗?
最佳答案
在 SWI-Prolog 中,您可以简单地使用 atomic_list_concat/3
和 atom_string/2
:
?- atomic_list_concat([apple, banana, oranges], ',', Atom), atom_string(Atom, String).
Atom = 'apple,banana,oranges',
String = "apple,banana,oranges".
关于string - Prolog 列表到逗号分隔的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5879956/