对城市进行分组的序言程序

发布于 2024-12-03 03:07:33 字数 498 浏览 0 评论 0原文

我在这里需要帮助,这是一个作业

序言程序,显示哪些城市位于

尼日利亚东南部。以下是城市(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱的故事 2024-12-10 03:07:33

处理(序言)问题时要做的第一件事就是根据您需要的查询为您的数据选择合适的表示形式。

在这种情况下,您将需要像 is_city_in_south_east(City) 这样的谓词。
因此,您可以将数据表示为:

is_city_in_SOuth_east(abraka).
is_city_in_south_east(awka).
city_is_not_in_south_east(oyo).
....

但是,这种表示方式过于具体。
更普遍的是,

city_location(abraka, south_east).
city_location(awka).
city_location(oyo, not_south_east).

我假设这

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)

只是数据库的人类可读表示。

如果这是程序的实际输入(例如在文本文件中),那么它会非常混乱;我认为最简单的方法是构建一个迷你解析器。

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:

is_city_in_SOuth_east(abraka).
is_city_in_south_east(awka).
city_is_not_in_south_east(oyo).
....

however, this representation is too specific.
something more general would be

city_location(abraka, south_east).
city_location(awka).
city_location(oyo, not_south_east).

I assumed that the

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)

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文