Have to find the longest word possible out of a list of given letters PROLOG -
:-consult(words.pl). % words big database of % 30.000 used words in english language topsolution([], _, p) :- %basecase, in case given list of letters %empty, output no word , give amount of letters %and call p word(x), %sees if x word p = 0. topsolution(wordlist, x, p) :- %makes longest word can out of list %of letters , outputs said word x, , %amount of letters has p y = 0, solution(wordlist, x, y), %determines words can make given %list of letters , given length of said word y1 y + 1, solution(wordlist, x, y1), %determines longest word of y + 1 wordlength(p, x). %defines how many letters word x has , calls amount p so piece of code made find word. problem i'm struggling can't find way make recursion stop. if input: ?-