Prolog is a programming language created in 1972 by Alain Colmerauer.
#32on PLDB | 52Years Old | 23kRepos |
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...
:- initialization main.
main :-
write("Hello, world!"), nl.
helloWorld :-
write('Hello World').
:- helloWorld.
% Hello World in Prolog
hello :- display('Hello World!') , nl .
%6.8
subset(Set, Subset) :-
append(L1, Subset, Set).
powerset(Set, Subset) :-
bagof(Subset, subset(Set, Subset), Subset).
rule(q0, 1, q0, 1, right).
rule(q0, b, qf, 1, stay).
Feature | Supported | Example | Token |
---|---|---|---|
Standard Library | ✓ | write('Hello, World!'), nl. | |
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 |