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!

Counting in prolog

Status
Not open for further replies.

othererik

Programmer
May 23, 2004
1
US
I am trying to find the largest word out of several thousand instances of word(apple). word(bob). .. and so on. I am a noobie at this, but here is my current (not working) attempt:
maxlength(Start):-
word(X),
equal(Counter, Start),
string_atom(Y, X),
string_length(Y, Length),
Length > Counter ->
(cntr_set(Counter, Length), write(Counter);
write($Not Greater$)),
write(Counter), write(Length).

Any help would be wonderful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top