Here is how we write the prolog hello world program:
The code idea of the prolog is : relation(object1, object2, ..., objectn)
, and the objects
in here also called atoms
. The relation
is called predicate
, the objects object1, object2, ..., objectn
involved in the relation are the arguments
, and the number n of the arguments is the arity
.
English | Predicate Calculus | Prolog |
---|---|---|
If | –> | :- |
Not | ~ | Not |
Or | V | ; |
and | ^ | , |
We can easily define the list just like in Python or somewhere else. The things in the list will be called “element”.
1 | [] |
We can seperate the list into the head
and tail
:
1 | [a|[]] which equals to [a] |
The prolog can cover the characters into the list:
1 | "abc" = [a, b, c]. |