Anagram - back to content

Anagram - a word or phrase spelled by rearranging the letters of another word or phrase.
		?- start.
		Write a word= max.
		max     amx     axm     mxa     xma     xam     no
		?- add(a,[b,c,d],X).
		X = [a,b,c,d]
		X = [b,a,c,d]
		X = [b,c,a,d]
		X = [b,c,d,a]
		?- permut([a,b,c],X).
		X= [a,b,c]
		X= [b,a,c]
		X= [b,c,a]
		X= [a,c,b]
		X= [c,a,b]
		X= [c,b,a]

start:- write('Write a word='),read(X),nl, name(X,L),permut(L,R), name(Cuv,R),write(Cuv),tab(5),fail. add(X,L,[X|L]). add(X,[L|H],[L|R]):- add(X,H,R). permut([],[]). permut([L|H],R):- permut(H,R1),add(L,R1,R).