Questions Concepts
GitHub icon


Prolog - Programming language

< >

Prolog is a programming language created in 1972 by Alain Colmerauer.

#40on PLDB 51Years Old 23kRepos

Try now: Riju

Prolog is a general-purpose logic programming language associated with artificial intelligence and computational linguistics. Prolog has its roots in first-order logic, a formal logic, and unlike many other programming languages, Prolog is intended as primarily a declarative programming language: the program logic is expressed in terms of relations, represented as facts and rules. A computation is initiated by running a query over these relations. Read more on Wikipedia...

Example from Riju:
:- initialization main. main :- write("Hello, world!"), nl.
Example from hello-world:
helloWorld :- write('Hello World'). :- helloWorld.
% Hello World in Prolog hello :- display('Hello World!') , nl .
Example from Linguist:
%6.8 subset(Set, Subset) :- append(L1, Subset, Set). powerset(Set, Subset) :- bagof(Subset, subset(Set, Subset), Subset).
Example from Wikipedia:
rule(q0, 1, q0, 1, right). rule(q0, b, qf, 1, stay).

Language features

Feature Supported Token Example
Binary Literals
% 0b[01]+
% \d\d?\'[a-zA-Z0-9]+
% (\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?
% 0x[0-9a-fA-F]+
% 0o[0-7]+
Case Sensitivity
Strings '
'Hello world'
MultiLine Comments /* */
/* A comment
Print() Debugging write
Line Comments %
% A comment
term_expansion(parent_child(Parent, Child),
             child_parent(Child, Parent)).
parent_child(trevor, simon).
% With the above definitions, we can query (even though the predicate child_parent/2 is nowhere explicitly defined in the code above):
?- child_parent(Child, Parent).
 Child = simon, Parent = trevor.
Type Inference
Case Insensitive Identifiers X
Semantic Indentation X

View source

- Build the next great programming language · Search · Add Language · Features · Creators · Resources · About · Blog · Acknowledgements · Queries · Stats · Sponsor · Traffic · Traffic Today · Day 305 · · Logout