Guess the word - back to content

		The program has "in mind" a word (love) and you have to guess this word: letter by letter.
		Unless you don't guess the first letter the program does not ask for the next letter.
		If you guess a letter the program says: OK. And asks for the next one.

?- start. Guess first letter|: m. false. ?- start. Guess first letter|: l. OK. Next letter|: a. Fail. Try again! Next letter|: o. OK. Next letter|: v. OK. Next letter|: e. OK. Congratulations! The word is [l,o,v,e] true.
in_mind([l,o,v,e]). start:- write('Guess first letter'),read(X), in_mind([X|T]),write('OK. '),guess(T). guess([]):- write('Congratulations! The word is '),in_mind(W),write(W),!. guess(L):- repeat,write('Next letter'),read(X), ((L=[X|T1],write('OK. '),guess(T1)); (write('Fail. Try again!'),guess(L))).