News for hackers. Stuff that matters.
Re:Programming paradigms that change how people think about ... by YeGoblynQueenne on Friday March 08, 2019 @06:12AM (#19336599)
Prolog is declarative, but it's very different to SQL and it's a shame to put the two together. It is much more interesting to examine Prolog from the logic programming point of view.

Also:

1) The sorting example is O(n!) not because of limitations of the language, as the article suggests, but because the algorithm implemented is permutation sort, which is O(n!).

A typical sorting algorithm example in Prolog is merge sort which is as efficient in Prolog as merge sort can be. Here are a few sorting algorithms in Prolog, including merge sort and quick sort:

http://kti.ms.mff.cuni.cz/~bartak/prolog/sorting.html

2) The Sudoku example uses a Constraint Logic Programming library implemented in Prolog (from the looks of it, Gnu Prolog). CLP is a different paradigm than plain logic programming, where one programs by specifying constraints.

A Sudoku solver in actual Prolog can be found in "99 Prolog Problems":

https://www.ic.unicamp.br/~meidanis/courses/mc336/2009s2/pro...

The sudoku solver is number 97.

There are no comments on this comment yet.