Code Comments
Programming Forum and web based access to our favorite programming groups.hi all, im new to prolog and im trying to make this pred. compare[a,a,a,a]. yes compare[a,e,a,t]. no so if the element of the list are the same then its a yes if not then its a no how can i do this? i was trying this but it didnt work compare([H|T]):- element(H, [H|T]). element(H, [H|T]):- element(H,T). but this is wronge. anyone can help me plz?
Post Follow-up to this messageurdad@hotmail.com (kimos) writes: > hi all, > im new to prolog > > and im trying to make this pred. > > compare[a,a,a,a]. > yes > > > compare[a,e,a,t]. > no > > > so if the element of the list are the same then its a yes if not then its a no > > how can i do this? > > i was trying this but it didnt work > > compare([H|T]):- > element(H, [H|T]). > element(H, [H|T]):- > element(H,T). > > but this is wronge. anyone can help me plz? What is element's base case? It needs a fact to know if the recursive procedure is successful by stating how the final step should appear. Hopefully this hint will provoke you to add a simple line of code. -- gnupg fingerprint: 4055 65EC 24D1 1DC2 700C 6654 6009 4AB9 F4C3 3E7E
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.