Prolog for Dummies
Hello World
Here is how we write the prolog hello world program:
Core Idea
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 | ^ | , |
List
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 |
|
The prolog can cover the characters into the list:
1 |
|
Prolog for Dummies
http://xiaos.site/2022/10/02/Prolog-for-Dummies/