Wouter Wielhouwer
Wouter Wielhouwer

Reputation: 13

Why does it say my predicate block/3 is not called?

So I've been learning Prolog, and to test myself I wanted to solve a certain puzzle. I think I'm pretty close to solving it, but I seem to be doing something wrong. It seems my predicate block/3 is not called.

maybe it's a syntax error, or I'm doing something that doesn't work in Prolog. I can't see it.

predicate not called

block/3 is supposed to give all possible combinations of sets in block/2.

I'm not sure if it's entirely relevant but I'll include the goal of the puzzle:

There's four cubes, with different combination of four images on their faces. (Kim,Lab,Hail and Com)
The goal is to align the cubes in such a way that if you put them together, all the sides next to each other should be the same. So it's four of the same rows going around each cube, and then two sides that should also be matching.

I wrote the program to just solve the rows, and disregarding the orientation of the images and the two sides. Should that give more than one answer it shouldn't give too many to manually try.

anyway, somehow solve(X) completely ignores my predicate block/3. I've been staring at it for a long time and I can't find the issue.

Upvotes: 1

Views: 295

Answers (1)

Will Ness
Will Ness

Reputation: 71099

 member( block(1, _, Row), X )

is equivalent to

 E = block(1, _, Row), member( E, X )

so it does not in fact call block/3 as a predicate, it just uses it as a compound term, symbolically.

Upvotes: 2

Related Questions