这个语法是什么意思?(序言) [英] What does this syntax mean? (Prolog)

查看:49
本文介绍了这个语法是什么意思?(序言)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试学习 Prolog,并在一些示例代码中遇到了这种语法.

I have been trying to learn Prolog and came across this syntax on some example code.

solve(Hs) :- Hs = [_,_,_,_,_],
    member(h(_, _, _, _, dog), Hs).

这只是代码的一部分,但我对 h(_,_,_,_,dog)does 感到困惑.

This is only a portion of the code, but I'm confused with the h(_,_,_,_,dog)does.

任何帮助将不胜感激!

推荐答案

下划线 _ 只是表示那个位置有值,但我们不关心它.

The underscores _ just indicate that there is a value in that position, but we don't care about it.

第一部分有效地说明了 Hs 是一个 5 项列表.第二部分说在 Hs 的列表中,其中一项是复合词 h/5(h 有 5 个子词),其中最后一个是原子,<代码>狗.

The first part effectively says that Hs is a 5 item list. The second part says that in that list of Hs, one of the items is a compound term h/5 (h with 5 subterms) where the last is the atom, dog.

这篇关于这个语法是什么意思?(序言)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆