SetUtils

object SetUtils
class Object
trait Matchable
class Any

Value members

Concrete methods

def pSet[A](set: Set[A]): LazyList[(Set[A], Set[A])]

Tail recursive pSet pSet s generates the power set of s, pairing each subset with its complement. Example: pSet(Set(1,2)) = Stream((Set(1,2),Set()),(Set(1),Set(2)),(Set(2),Set(1)),(Set(),Set(1,2))).

Tail recursive pSet pSet s generates the power set of s, pairing each subset with its complement. Example: pSet(Set(1,2)) = Stream((Set(1,2),Set()),(Set(1),Set(2)),(Set(2),Set(1)),(Set(),Set(1,2))).

def partition[A](set: Set[A], n: Int): LazyList[List[Set[A]]]

paritition of a set in n sets whose union give that set again Example: partition(Set(1,2),2) = Stream( List(Set(1, 2), SetInt), List(Set(2), Set(1)), List(Set(1), Set(2)), List(SetInt, Set(1, 2)) )

paritition of a set in n sets whose union give that set again Example: partition(Set(1,2),2) = Stream( List(Set(1, 2), SetInt), List(Set(2), Set(1)), List(Set(1), Set(2)), List(SetInt, Set(1, 2)) )

partition(Set(1,2),3) = Stream( List(Set(1, 2), SetInt, SetInt), List(Set(2), Set(1), SetInt), List(Set(2), SetInt, Set(1)), List(Set(1), Set(2), SetInt), List(Set(1), SetInt, Set(2)), List(SetInt, Set(1, 2), SetInt), List(SetInt, Set(2), Set(1)), List(SetInt, Set(1), Set(2)), List(SetInt, SetInt, Set(1, 2)) )

Type Params
A

type of values

Value Params
n

number of sets to generate

set

set of elements

Returns

a list of sets