use Sets instead of Lists

@williamboxhall The inputs/outputs shouldn't have duplicated elements and the order is not necessary.
@williamboxhall your last example doesn't compile, since ```traverse``` receives a ```List[T]```.