/* Turn around words in Picat. (Swedish): https://www.facebook.com/groups/utvecklare.stockholm/permalink/1829765210405876/?notif_id=1534701480620961¬if_t=group_highlights """ https://twitter.com/ptornroth/status/1030890867417145344?s=21 ''' Funderar på sammansatta ord som går att byta ordning på, och då få en helt annan betydelse. Exempel: torsksoppa / soppatorsk Finns det fler? ''' """ Result: http://hakank.org/picat/turnaround_words2.txt English translation """ Thinking about compound words that one can switch the order of the words, and then get a completely different meaning. Example: mateship / shipmate. Are there more? """ Turnaround words in English: http://hakank.org/picat/turnaround_words_eng.txt This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ main => go. go => File = "sv_spelling_org_utf8.txt", % Swedish wordlist % File = "words_lower.txt", % English wordlist Words = new_map([W=1 : W in read_file_lines(File), W.len >= 2]), foreach(Word=_ in Words) All = findall([X,Y], append(X,Y,Word)), foreach([A,B] in All, A != B, A.len >= 2, B.len >= 2, Words.has_key(A),Words.has_key(B)) W2 = B++A, if Words.has_key(W2) then println(Word=W2) end end end, nl.