Teacup rim text: Difference between revisions

m (→‎{{header|Python}}: added zkl header)
(→‎{{header|zkl}}: added code)
Line 745:
 
=={{header|zkl}}==
<lang zkl>// this is limited to the max items a Dictionary can hold
<lang zkl></lang>
words:=File("unixdict.txt").pump(Dictionary().add.fp1(True),"strip");
<lang zkl></lang>
seen :=Dictionary();
foreach word in (words.keys){
rots,w,sz := List(), word, word.len();
if(sz>2 and not seen.holds(word)){
do(sz-1){
w=String(w[-1],w[0,-1]); // rotate one character
if(not words.holds(w)) continue(2); // not a word, do next word
rots.append(w); // I'd like to see all the rotations
}
println(rots.append(word).sort().concat(" "));
rots.pump(seen.add.fp1(True)); // we've seen these rotations
}
<lang zkl>}</lang>
{{out}}
<pre>
aaa aaa aaa
 
apt pta tap
ate eat tea
arc car rca
iii iii iii
</pre>
Anonymous user