static ItIt anagrams_iterator(S s) { Set seen = litciset(s); ret filterIterator(l -> add(seen, join(x)), allPermutations_iterator(characters(s))); }