can't really figure out where to make it return no, i tried all possible ways of adding fail or !.
here is the final code
binpack(_,_,[],AnswerListOfLists):- !. %if no input is provided exit
%Predicate binpack/4 which operates in mode (+,+,+,-)...
ok done it, it works perfect. but i need one more last advice
here is the code:
binpack(_,_,[],AnswerListOfLists):- !.
binpack(NumBins,Capacity,ObjectList,AnswerListOfLists):-
createBins([[]],NumBins,Bins),
(addIn(ObjectList,Capacity,Bins,AnswerListOfLists);
perm(ObjectLisT,RandomList)...
thank you joel very much, you've been really helpful thanks. This works fine,but i still need to figure out one thing: when a number comes that doesn't fit in any bin the program fails, if that happens i need it go back, re-arrange the object list and start again from the start.
here is what...
your answer confused me a little bit, so one change is to make C=< Cap do nothing when it fails? or just leave it as it is? and the second change is to do something when all numbers are used?
this is what i tried to do but now 2 things happen, when it reaches the last bin and the next number...
ok fixed that but now a different problem here is the code:
binpack(NumBins,Capacity,ObjectList,AnswerListOfLists):-
createBins([[]],NumBins,Bins),
addIn(ObjectList,Capacity,Bins,AnswerListOfLists).
createBins(L1,N,L2):-createBins(L1,N,L2,N).
createBins([],_,[],_).
createBins([_|Xs],N,Ys,0)...
ok found how to do that but now i have an other problem here is my code:
binpack(NumBins,Capacity,ObjectList,AnswerListOfLists):-
createBins([[]],NumBins,Bins),
addIn(ObjectList,Capacity,Bins,AnswerListOfLists).
createBins(L1,N,L2):-createBins(L1,N,L2,N).
createBins([],_,[],_)...
Hello i need to create a list of empty lists eg [ [], [] , [] , []] but the problem is, i need the exact number of empty lists provided from the input.. for example if i give createEptyLists(4,X). it should return X= [ [], [] , [] , [] ].
how can i implement this " for i=<InputNumberOfLists" ?
ok , sorry about this, i got another problem. I am supposed to read several lines from the text, for example the txt file looks like:
three plus zero.
two times four.
stop.
two minus one.
so I need to make the program read all the lines until it finds a stop, and print the results in a new...
thanks for the reply, sadly i need this to work in gprolog and use read_atom (which is not supported in swi-prolog) to read from a txt file.
so with your help i changed the code to this:
num(one,1).
num(two,2).
num(three,3).
num(four,4).
num(five,5).
num(six,6).
num(seven,7).
num(eight,8)...
Hi, I need to build this program to read from a file sentences like "three plus zero." (all of them 3 words and just a simple operation) and return the result of the arithmetic operation. The solution I thought of was to use read_atom to store each word in X,Y,Z atoms. then make a list of them...
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.