Measures Concepts
GitHub icon

Prolog

Prolog - Programming language

< >

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

#40on PLDB 52Years 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]+
Integers ✓
% \d\d?\'[a-zA-Z0-9]+
Floats ✓
% (\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?
Hexadecimals ✓
% 0x[0-9a-fA-F]+
Octals ✓
% 0o[0-7]+
Case Sensitivity ✓
Strings ✓ '
'Hello world'
MultiLine Comments ✓ /* */
/* A comment
*/
Print() Debugging ✓ write
Line Comments ✓ %
% A comment
Macros ✓
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 ✓
Comments ✓
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 · Day 605 · feedback@pldb.io · Logout