I was working on the pangram exercise on exercism.io, and this was my solution: from strutils import toLowerAscii from sequtils import toSeq import sets const letters = toSeq("abcdefghijklmnopqrstuvwxyz".items).toSet() func isPangram*(text: string): bool = return toSet(toSeq(text.toLowerAscii().items)) >= letters Run
The thing is, sets doesn't even have a >= operator declared. I can't for the life of me find where it comes from, because if I try to explicitly import it from the sets package, it doesn't work. I decided to rewrite my code to get rid of the missing operator. I also wanted to be a bit more explicit just to make sure the typing system isn't doing strange things: from strutils import toLowerAscii from sequtils import toSeq import sets const letters : HashSet[char] = toSeq("abcdefghijklmnopqrstuvwxyz".items).toSet() func isPangram*(text: string): bool = var mySet : HashSet[char] = toSet(toSeq(text.toLowerAscii().items)) return sets.`<=`(letters, mySet) Run So far so good, it still works. And, sets has a <= operator. So it must be coming from the sets package. I will try to fully qualify everything again: from strutils import toLowerAscii from sequtils import toSeq from sets import HashSet, toSet, `<=` const letters : HashSet[char] = toSeq("abcdefghijklmnopqrstuvwxyz".items).toSet() func isPangram*(text: string): bool = var mySet : HashSet[char] = toSet(toSeq(text.toLowerAscii().items)) return sets.`<=`(letters, mySet) Run And now it doesn't work. mySet and letters are clearly the same type, but the compiler complains: > C:Appsnim-0.19.4libpurecollectionssets.nim(590, 15) Error: type mismatch: got <HashSet[system.char]> > but expected one of: > iterator items[T](s: HSlice[T, T]): T > iterator items(a: cstring): char > iterator items[T](a: seq[T]): T > iterator items[T](a: openArray[T]): T > iterator items(a: string): char > iterator items[T](a: set[T]): T > iterator items(E: typedesc[enum]): E:type > iterator items[IX, T](a: array[IX, T]): T > > expression: items(s) I'm quite confused, perhaps someone here could help me. Thank you!