Questions tagged [prolog]

Prolog is the most commonly used logic programming language. It supports non-deterministic programming through backtracking and pattern matching through unification.

10 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
0answers
55 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 ...
3
votes
0answers
117 views

Writing a tokenizer in SWI-Prolog

To teach myself how to do meta-progaming 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 "...
3
votes
0answers
200 views

Movie Knowledgebase

I have had an assignment to construct a movie knowledgebase and ten specified queries in Prolog. This is my first ever Prolog program, so I would appreciate any pointers toward how I could improve. ...
3
votes
0answers
13k views

Monkey-banana problem in Prolog

The monkey-banana problem: There many variations to this problem, but the basic premise is that a monkey is in a room with a banana and a chair, and the monkey cannot reach the banana until he moves ...
2
votes
0answers
27 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. ...
2
votes
0answers
22 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 ...
2
votes
0answers
125 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 ...
2
votes
0answers
29 views

meta predicates fixedpoint/3 and fixedpointlist/3

What about the following meta-predicate "fixed point"? ...
1
vote
0answers
20 views

Prolog destructor?

I have an init predicate which asserts some facts. I would like to clean these up after execution. I'm running queries of the form init, do_stuff, cleanup.. I would ...
1
vote
0answers
92 views

Echo in Prolog with single print (new version)

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 requirements: It makes only one I/O call ...