/* Rotational words in Picat. From https://twitter.com/avadeaux/status/1603420481343918085 (In Swedish) """ Likväl: ikväll. Dessa ord är alltså rotationer av varandra, det var det jag just insåg. (Eller finns det ett finare ord än rotation, något som slutar på -om? Vet @ola_t?) """ [Approximate translation: evens: seven So these words are rotations of each other, that was what I realized. (Or is there a fancier word than 'rotation', something that ends with -om? Does @ola_t know? ] (I first thought of 'chiasmus' but that's not the proper term...) Svenska ord: http://hakank.org/picat/rotational_words_swe.txt abelsk = kabels abort = borta adlades = sadlade adlas = sadla adlat = tadla adlats = sadlat adress = dressa adresser = dressera akromatisk = kromatiska alarm = larma alarm = malar deaktivera = aktiverade etthundra = hundraett English words: http://hakank.org/picat/rotational_words_eng.txt Some examples: evil = vile evil = levi evocated = devocate evoker = revoke evolved = devolve evolver = revolve exploitations = sexploitation gunderson = undersong (@ola_t thought of "rotagrams" and found this site: https://datagenetics.com/blog/january32019/index.html ) This program 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 Words = read_file_lines(File), Set = new_set(Words), foreach(W1 in Words) Perms = find_rotations(W1), % Perms = find_rotations_2(W1,Set), % skip "word swaps" foreach(W2 in Perms, Set.has_key(W2) ) println(W1=W2), flush(stdout) end end, nl. find_rotations(W1) = findall(W2,(append(A,B,W1), A != "", B != "", W2=B++A)). % Skip words that is just a rotation of words in the word list. find_rotations_2(W1,Set) = findall(W2,(append(A,B,W1), A != "", B != "", not Set.has_key(A), not Set.has_key(B), W2=B++A, W2!=W1)).