Replies: 3 comments 18 replies
-
That functionality is provided by some libraries. E.g. |
Beta Was this translation helpful? Give feedback.
-
It seems everything to say about this code has already been stated elsewhere and also quite recently, so I post here only a query showing a mistake in the program: ?- check(is_long, A, B). A = [_A,_B,_C,_D,_E,_F], B = true, unexpected, incomplete This is a mistake in the program, since adding a constraint elicits an answer not shown above: ?- A = [_,_,_,_,_,_,_], check(is_long, A, B). A = [_A,_B,_C,_D,_E,_F,_G], B = true. The program thus violates a fundamental property we expect from logic programs: Adding a constraint does not yield new solutions. For readers interested in previous posts on this topic, here is a small collection of recent related discussions:
To benefit most from Prolog, you must keep to its pure monotonic core. Try to think in terms of relations and use pure predicates to state what holds. The link to a nice enumeration and classification of pure predicates was recently posted in #1937 (reply in thread). A small number of such predicates suffices to express a great number of Prolog programs with nice declarative properties that we can benefit from when debugging and reasoning about our code. If you use constructs outside this subset, then you do not benefit from these properties, and thus miss a key attraction of logic programming. |
Beta Was this translation helpful? Give feedback.
-
Emacs is indeed recommended by some people. But there are plenty of other choices, varying on their support for Prolog programming. See e.g. https://github.com/LogtalkDotOrg/logtalk3/tree/master/coding for other options. Some systems provide their own IDE (e.g. ECLiPSe, SICStus Prolog, SWI-Prolog, ...).
There's certainly life outside Prolog pure monotonic core. Outside the classroom, programmers have long been writing applications whose feasibility and effectiveness require stepping outside that core. For many of those applications, the top-level is irrelevant, not every predicate is required to be a relation, and striving to always write the most general predicate definitions would actually be detrimental. Application requirements rule. Applications don't exist in splendid isolation. They talk with the outside world, connect to databases and services, integrate with existing IT systems. For industry practitioners, Prolog is often used and promoted as a general purpose language. The aim is not to build perfect bridges but usable bridges. |
Beta Was this translation helpful? Give feedback.
-
I wrote a
list_matching
rule that relates the list L0 to the list L which contains all elements for which predicate P holds.Is there a better way to implement this? I feel like the associated
check
rule is more complicated than it should be.Beta Was this translation helpful? Give feedback.
All reactions