我希望此输出为字符串格式。 怎么办呢?
我得到的输出:
[[[[a]|fat]|man],[[[[[was]|walking]|quickly],to],[[[[the]]|end],[of,[[[the]|long]|corridor]]]]]
预期产出:
a fat man was walking quickly to the end of the long corridor
答案 0 :(得分:3)
您可以使用flatten/2
和atomic_list_concat/3
:
:- X = [[[[a]|fat]|man],[[[[[was]|walking]|quickly],to],[[[[the]]|end],[of,[[[the]|long]|corridor]]]]],
flatten(X,Y),
atomic_list_concat(Y,' ',Z).
X = [[[[a]|fat]|man], [[[[[was]|walking]|quickly], to], [[[[the]]|end], [of, [[...|...]|...]]]]],
Y = [a, fat, man, was, walking, quickly, to, the, end|...],
Z = 'a fat man was walking quickly to the end of the long corridor'.