Top "Prolog" questions

Do not use this tag like Prologue and Epilogue.

How to transpose a matrix in prolog

How can I transpose a list like [[1,2,3][4,5,6][6,7,8]] to [[1,4,6],[2,7,8],[3,6,9]]? To depict it: I'd like to flip the matrix 90 degree to the …

list matrix prolog transpose
Prolog existence_error following Seven Languages in Seven Weeks

I'm just following the book Seven Languages in Seven Weeks. I've installed gprolog in my Mac machine using command port …

prolog
Predicate control in Prolog

Have a curiosity related to Prolog predicate control. Supposedly I have a predicate f(A,X) and g(B). f(…

prolog predicate
Hello world in Prolog

I'm tearing my hair out trying to find how to just write a Hello World program in Prolog. I just …

prolog read-eval-print-loop
Cut and Fail in Prolog

Consider the following code: a(X) :- b(X),!,c(X),fail. a(X) :- d(X). b(1). b(4). c(1). …

prolog prolog-cut
What are the best uses of Logic Programming?

By Logic Programming I mean the a sub-paradigm of declarative programming languages. Don't confuse this question with "What problems can …

functional-programming prolog logic logic-programming
I'm new to Prolog. Trying to run this code but gives - ERROR: Undefined procedure: teaches/2 (DWIM could not correct goal)

These are the facts I have written instructor(ahmed,mohammed, cs101,01). instructor(sara,salah,cs101,02). instructor(maryam,faisal,cs101,03). instructor(…

prolog undefined procedure
How to create global variable in prolog

I have a list that I create as follows: tab([(top,left),(top,middle),(top,right),(center,left),(center,middle), (…

list variables prolog global reusability
Solve Cannibals/Missionaries using breadth-first search (BFS) in Prolog?

I am working on solving the classic Missionaries(M) and Cannibals(C) problem, the start state is 3 M and 3 C …

prolog breadth-first-search river-crossing-puzzle
Comparing SQL and Prolog

I've started learning Prolog and wondering about the theoretical difference from the SQL language. For example: both are declarative languages …

sql prolog