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
Hsis a 5 item list. The second part says that in that list ofHs, one of the items is a compound termh/5(h with 5 subterms) where the last is the atom,dog.