开发者

What does this syntax mean? (Prolog)

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

solve(Hs) :- Hs = [_,_,开发者_运维技巧_,_,_],
    member(h(_, _, _, _, dog), Hs).

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

Any help would be greatly appreciated!


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

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.


All the underscores can match anything. It is a wild card. You are basically looking for a fact(?) with the last part equal to dog.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜