ok
how about using set_of on youre right_to function.
This should give u the list of each block on the desk starting from the one on the left.
You dont have to do it this way but using the built in predicate last can help you find the last one in the list.
In SWIProlog enter help(last). Which...
setof(+Template, +Goal, -Set)
Equivalent to bagof/3, but sorts the result using sort/2 to get a
sorted list of alternatives without duplicates.
Is what i get, so i guess I'll have to hold ya hand.
+Template = the variable u want ie X, goal is the goal i.e a predicate that must be...
what you need to do is define a predicate for finding all the blocks on a stack.
I am also assuming u need to find all the blocks to the right of a block even if the block is on a stack. So you need to find the base.
Then apply youre right_to predicate to the base.
So you may end up with two...
This sounds very similar to a coursework I am doing at present , which was advised to use the built in function setof/3 .
If you do a help(setof). in swiProlog it will provide information on how this is defined.
Hope this helps
XXX
Atilla
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.