 	/// Returns a new set with all elements from the receiver which are not contained in `set`.
 	public func difference(set: Set) -> Set {
 		return Set(filter(self) { !set.contains($0) })
+	}
+
+
+	// MARK: Higher-order functions
+
+	/// Returns a new set with the result of applying `transform` to each element.
+	public func map<Result>(transform: Element -> Result) -> Set<Result> {
+		return flatMap { [transform($0)] }
+	}
+
+	/// Applies `transform` to each element and returns a new set which is the union of each resulting set.
+	public func flatMap<Result, S: SequenceType where S.Generator.Element == Result>(transform: Element -> S) -> Set<Result> {
+		return reduce(Set<Result>()) { $0 + transform($1) }
+	}
+
+	/// Combines each element of the receiver with an accumulator value using `combine`, starting with `initial`.
+	public func reduce<Into>(initial: Into, combine: (Into, Element) -> Into) -> Into {
+		return Swift.reduce(self, initial, combine)
 	}
 
 

}


/// Higher-order functions.
extension Set {
	/// Returns a new set with the result of applying `transform` to each element.
	public func map<Result>(transform: Element -> Result) -> Set<Result> {
		return flatMap { [transform($0)] }
	}

	/// Applies `transform` to each element and returns a new set which is the union of each resulting set.
	public func flatMap<Result, S: SequenceType where S.Generator.Element == Result>(transform: Element -> S) -> Set<Result> {
		return reduce(Set<Result>()) { $0 + transform($1) }
	}
}

/// Extends a `set` with the elements of a `sequence`.
public func += <S: SequenceType> (inout set: Set<S.Generator.Element>, sequence: S) {
	set.extend(sequence)

/// Defines equality for sets of equatable elements.
public func == <Element: Hashable> (a: Set<Element>, b: Set<Element>) -> Bool {
	return a.values == b.values
}


