/* Mutants in Picat. Inspired by the PrologII+ program mutant.p2 A mutant word is a combination of two words where the suffix of the first word is a prefix of the second word. The PrologII+ program combined these French words (animals): alligator tortue caribou ours cheval vache lapin pintade hibou bouquetin chevre into these mutant words (go20): alligatortue caribours caribouquetin chevalligator chevalapin vacheval vachevre lapintade hibours hibouquetin Added mutant_words/5 which "mutant" words from a wordlist, including MinLen which is the minimum length of the common pre-/suffix. This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ main => go. /* Some examples with MinLen 4: [abeyance,ancestral,abeyancestral] [abeyance,ancestry,abeyancestry] [abigail,gaillardia,abigaillardia] [ablate,laterite,ablaterite] [aboard,boardinghouse,aboardinghouse] [aboriginal,inalienable,aboriginalienable] [aboriginal,inalterable,aboriginalterable] [about,boutique,aboutique] [above,aboveboard,aboveboard] [above,aboveground,aboveground] "Self mutant" words: [alfalfa,alfalfa,alfalfalfa] [antiperspirant,antiperspirant,antiperspirantiperspirant] [beriberi,beriberi,beriberiberi] [calendrical,calendrical,calendricalendrical] [couscous,couscous,couscouscous] [einstein,einstein,einsteinstein] [hotshot,hotshot,hotshotshot] [murmur,murmur,murmurmur] [oshkosh,oshkosh,oshkoshkosh] [tarantara,tarantara,tarantarantara] [tartar,tartar,tartartar] [testes,testes,testestes] */ go ?=> File = "unixdict.txt", MinLen = 4, mutant_words(File,MinLen, X,Y,Z), println([X,Y,Z]), fail, nl. go => true. % % PrologII+ version % Mutant animals. % go2 ?=> mutant(X), println(X), fail, nl. go2 => true. % % read a word list and find words that can be "mutanted" % % mutant_words(File,MinLen, X,Y,Z) => % Words = $[w(W) : W in read_file_lines(File), length(W) > MinLen], % println(words_read), % cl_facts(Words), cl_facts($[w(W) : W in read_file_lines(File), length(W) > MinLen]), println(cl_finished), % pick any two (different) words w(X), w(Y), X != Y, % X == Y, % self mutant word append(A,B,X), % B is the suffix of X A != [], B.len >= MinLen, append(B,C,Y), % B is the prefix of Y C.len >= MinLen, append(X,C,Z), % combine prefix of X and suffix of Y not(w(Z)). % don't accept existing words % % From PrologII+ program mutant.p2 % mutant(Z) => animal(X), animal(Y), append(_A,B,X), B != [], append(B,C,Y), C != [], append(X,C,Z). index(-) animal("alligator"). animal("tortue"). animal("caribou"). animal("ours"). animal("cheval"). animal("vache"). animal("lapin"). animal("pintade"). animal("hibou"). animal("bouquetin"). animal("chevre").