对城市进行分组的序言程序
我在这里需要帮助,这是一个作业
序言程序,显示哪些城市位于
尼日利亚东南部。以下是城市(abraka、oyo、awka、
orlu、markurdi、jalingo、oweri、aba、mushin、okigwe)。
abraka (city not in south-east)
oyo (city not in south-east)
awka (city in south-east)
orlu (city in south-east)
markudi (city not in south-east)
jalingo (city not in south-east)
owerri (city in south-east)
aba (city in south-east)
mushin (city not in south-east)
okaigwe (city in south-east)
拜托,我不知道该怎么办。感谢您的任何
帮助。
Please I need help here, it's an assigment
A prolog program that shows which cities are in south-
east of Nigeria. Here are the cities (abraka, oyo, awka,
orlu, markurdi, jalingo, owerri, aba, mushin, okigwe).
abraka (city not in south-east)
oyo (city not in south-east)
awka (city in south-east)
orlu (city in south-east)
markudi (city not in south-east)
jalingo (city not in south-east)
owerri (city in south-east)
aba (city in south-east)
mushin (city not in south-east)
okaigwe (city in south-east)
Please I don't know exactly what to do. Thanks for any
help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
处理(序言)问题时要做的第一件事就是根据您需要的查询为您的数据选择合适的表示形式。
在这种情况下,您将需要像 is_city_in_south_east(City) 这样的谓词。
因此,您可以将数据表示为:
但是,这种表示方式过于具体。
更普遍的是,
我假设这
只是数据库的人类可读表示。
如果这是程序的实际输入(例如在文本文件中),那么它会非常混乱;我认为最简单的方法是构建一个迷你解析器。
One of the first things you shall do with a (prolog) problem is to choose a suitable representation for your data according to what queries you will need.
In this case, you will need to have a predicate like is_city_in_south_east(City).
Therefore, you could represent your data as:
however, this representation is too specific.
something more general would be
I assumed that the
was just a human-readable representation of the database.
In case this is the actual input of your program you (in a text file for example) it's quite messy; I think that the easiest way is to build a mini-parser.