Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prolog-operator "_:_" - meaning?

I do not understand the following Prolog snippet? What does ":_:" mean? What is the difference between ":=" and "=" ?

game_to_problematic_points(Game,Pid,Hid) :-
  Point := Game/point,
  Pid := Point@id,
  Point = point:_:Hits.
  append(_, [Hit1,_|_], Hits),
  hit_out(Hit1),
  Hid := Hit1@id.
hit_out(Hit) :-
  X := Hit@x,
  Y := Hit@y,
  ( X > 23.77 / 2
  ; X < -23.77 / 2
  ; Y > 10.97 / 2
  ; Y < -10.97 / 2).

Thanks :)

like image 201
CyKon Avatar asked Jul 17 '16 13:07

CyKon


1 Answers

This seems to be XPCE code. XPCE is the native SWI-Prolog object-oriented GUI library. You can find its manual in PDF format at:

http://www.swi-prolog.org/download/xpce/doc/userguide/userguide.pdf

The :=/2 operator is used for assignment (see the guide for details) while the =/2 is the standard Prolog unification operator.

The goal Point = point:_:Hits is simply the unification of the variable Point with the compound term point:_:Hits. It may be clear if you write this term in canonical form:

?- write_canonical(point:_:Hits).
:(point,:(_,_))
true.

Note that this term uses the standard :/2 module operator twice.

like image 158
Paulo Moura Avatar answered Sep 24 '22 09:09

Paulo Moura