Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  • Users: aa676
  • Order by date
  1. aa676

    Create a list of empty lists

    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 (+,+,+,-)...
  2. aa676

    Create a list of empty lists

    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)...
  3. aa676

    Create a list of empty lists

    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...
  4. aa676

    Create a list of empty lists

    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...
  5. aa676

    Create a list of empty lists

    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)...
  6. aa676

    Create a list of empty lists

    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([],_,[],_)...
  7. aa676

    Create a list of empty lists

    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" ?
  8. aa676

    Prolog Read a function from a file

    fixed it, this works: num(zero,0). num(one,1). num(two,2). num(three,3). num(four,4). num(five,5). num(six,6). num(seven,7). num(eight,8). num(nine,9). num(ten,10). plus(X,Y,Z):- num(X,NX), num(Y,NY), Z is NX + NY. minus(X,Y,Z):- num(X,NX)...
  9. aa676

    Prolog Read a function from a file

    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...
  10. aa676

    Prolog Read a function from a file

    fixed it, i was reading the number zero and i hadn't instantiated it. Thanks joel you were really helpfull ;)
  11. aa676

    Prolog Read a function from a file

    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)...
  12. aa676

    Prolog Read a function from a file

    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...

Part and Inventory Search

Back
Top