Doesn't that work?
> val setOfSets = Set[Set[String]]() setOfSets: scala.collection.immutable.Set[Set[String]] = Set() > setOfSets reduce (_ union _) java.lang.UnsupportedOperationException: empty.reduceLeft at scala.collection.TraversableOnce$class.reduceLeft(TraversableOnce.scala:152) [...]
Zoom out (left and right) cannot be applied to an empty collection.
Conceptually:
myCollection.reduce(f)
look like:
myCollection.tail.fold( myCollection.head )( f )
Thus, a collection must have at least one element.
This should do what you want:
setOfSets.foldLeft(Set[String]())(_ union _)
Although I did not understand the requirement not to indicate the order.
Source: https://habr.com/ru/post/894569/More articles:Convert method name to bean name at runtime? - javaDo not install Android Market INSTALL_REFERRER on Android 3.x - androidDifference between Value object template and data transfer template - javatimestamp 3 months ago - pythonA new line after the "Evidence" in the evidence environment in the package amsthm - latexWhat type of RDS instance has the best IO: Extra large database instance or Extra large high memory instance - amazon-rdsusing static methods of limited generic type C # - genericsHow to find a carriage return without feeding a line after it with a regular expression pattern? - c #Call Windows Task Manager with the selected Performance tab - c #The easiest javascript library to create custom tabs? - javascriptAll Articles