Questions tagged [prolog]
Prolog is the most commonly used logic programming language. It supports non-deterministic programming through backtracking and pattern matching through unification.
41
questions
3
votes
0
answers
45
views
Topological sort in Prolog
I wanted to calculate topological sort given a few predicates asserting that one element should be before another in a sequence. order(a, b) means that ...
3
votes
1
answer
54
views
maxlist(L, M) that succeeds if M is the max number in the list L
I'm working my way through "Prolog For Artificial Intelligence" by Ivan Bratko, and exercise 3.17 is to write a maxlist(L, M) that succeeds when ...
2
votes
0
answers
300
views
Temperature Scale Converter in Prolog
Problem statement:
Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, ...
1
vote
0
answers
195
views
Pocket cube solver in Prolog
Hello I have writtern this Prolog code to solve a scrambled 2x2 rubiks cube. Also known as a a pocket cube.
...
1
vote
1
answer
90
views
Prolog refactor if/else
How do I refactor this mess of if/else conditions so that it's more readable?
...
2
votes
0
answers
32
views
Simple task with recursion on Prolog
I'm new in Prolog. So, I'm not sure if my code is ok and optimized. I'm also not sure if I use recursion correctly.
Task: find students that has at least 1 bad grade (1 or 2) and print them in table
...
6
votes
1
answer
269
views
Constraint solving CrossCells puzzle game solution
There's a puzzle game called
CrossCells (not
affiliated; there's also multiple other ones with the same kind of idea,
but slightly different layout and rule set) that I've been playing on
and off. ...
3
votes
0
answers
77
views
Basic logic problem in Prolog
I thought it would be a good idea to take some easy to solve (by hand) problems and model them in Prolog for practice. Here is a problem I modeled in Prolog:
A messy kid wrote a multiplication ...
4
votes
0
answers
269
views
Writing a tokenizer in SWI-Prolog
To teach myself how to do meta-programming using Prolog, I've been playing around with translating ABNF syntax into DCG syntax. I'm still at the lexing and tokenising stage, but hope to advance to the ...
1
vote
2
answers
120
views
Find CISC prerequisites
Below I have some code written in prolog as a brief example. The goal of the program is to take a Computer and Information Science (CISC) course number and return any CISC prerequisites (prereqs).
I ...
2
votes
1
answer
518
views
Echo in prolog with single print
In order to learn a bit more of Prolog, I implemented the echo command for SWI-Prolog.
I want a correct implementation, that is, it satisfies the following ...
5
votes
1
answer
145
views
Counting number of seen states
I have some code which executes a simple task, counting the number of states reachable from a particular state, would just like some advice on how to improve it.
So far it stores all the states it ...
4
votes
2
answers
1k
views
Zebra puzzle in Prolog
I have attempted to a zebra puzzle in prolog and I was seeking some feedback as to the way I went about solving the puzzle.
Here is the puzzle:
Two weeks ago, four enthusiasts made sightings of ...
2
votes
0
answers
148
views
All outcomes for subtraction on each value in list individually
As you can see from my predicate iterate, I am repeating Z is X-3 and Z is X-2, the scenarios are different if the value is 0 or ...
4
votes
1
answer
17k
views
Family tree in Prolog
I tried to write a program in Prolog and describe a family tree:
...