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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick help in prolog please

Status
Not open for further replies.

cubearth

Programmer
Apr 8, 2010
2
TT
Am trying to get prolog to compare to list of atoms for occurencs in the same location. am also trying to get it to return a list with the occurences removed, but for some reason am getting a list with the occurences, and an unbounded veriable.
My code is below.
correct(_,_,0,_):-!.
correct([H|Seq],[H|Guess],Correct,EditGuess):- N is Correct-1, del(H,EditGuess,NList), correct(Seq,Guess,N,NList),!.
correct([H1|Seq],[H2|Guess],Correct,EditGuess):- Correct(Seq,Guess,Correct,EditGuess),!.

del(X,[X|Tail],Tail):-!.
del(X,[Y|Tail],[Y|Tail1]):- del(X,Tail,Tail1).

this is my test code:
23 ?- correct([a,b,c,d],[a,c,b,d],2,G).
G = [a, d|_G540].
 
Problem solved. Please ignore!
(Is there a way to delete post?)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top