Getting an error now:
8 ?- buy(X, L).
ERROR: >/2: Arguments are not sufficiently instantiated
And the code looks like this now.
kopa(X, [ingredient(_,_)|TS], R) :- kopa(X, [ingredient(_,_)|TS], R).
Sorry but it wont work :( The task is to show everything I need to buy to cook for exempel rise.
The code:
buy(X, L) :- at_home(YS), recipe(X,XS), kollabuy(XS, YS, L).
kollabuy([], _, []).
kollabuy([X|XS], YS, L1) :- kollabuy(XS, YS, L), kopa(X, YS, R), ( R = [], L1 = L, ! ; L1 = [R | L])...
Thanks for reply, but I'm not getting it to work :/
buy(X, L) :- at_home(YS), recipe(X,XS), kollabuy(XS, YS, L).
kollabuy([], _, _).
kollabuy([X|XS], YS, L) :- kopa(X, YS, L), kollabuy(XS, YS, L).
%No : when the homelist is empty, you have not foud the ingredient, you need to buy it and know...
I have write a program in Prolog, that will look in a list of ingredients and compare if you need to buy or what you can cook with all the ingredients you got home.
I have finish the first one that looks if I can cook for example rise. But I need to write a program that calculate how much I...
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.