首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >句子形式输出Prolog

句子形式输出Prolog
EN

Stack Overflow用户
提问于 2015-05-26 10:17:08
回答 1查看 91关注 0票数 0

我希望这个输出是字符串格式的。怎么做呢?

我正在获得的产出:

代码语言:javascript
复制
[[[[a]|fat]|man],[[[[[was]|walking]|quickly],to],[[[[the]]|end],[of,[[[the]|long]|corridor]]]]]

预期产出:

代码语言:javascript
复制
a fat man was walking quickly to the end of the long corridor
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-05-26 10:34:46

你可以用 atomic_list_concat/3

代码语言:javascript
复制
:- 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'.
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30455693

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档