 	///       [1, 2, 3, 4, 5].scanl(+, initial: 0) == [0, 1, 3, 6, 10, 15]
 	///
 	public func scanl<B>(f : B -> A -> B, initial : B) -> List<B> {
-		switch self.match() {
+		switch self.match {
 		case .Nil:
 			return List<B>(initial)
 		case let .Cons(x, xs):


	/// Yields a new list by applying a function to each element of the receiver.
	public func map<B>(f : A -> B) -> List<B> {
		switch self.match() {
		case .Nil:
			return []
		case let .Cons(hd, tl):

		let (hd, tl) = self.next()
		return List((hd, (tl + [hd]).cycle()))
	}
	
	/// Maps a predicate over a list.  For the result to be true, the predicate must be satisfied at
	/// least once by an element of the list.
	public func any(f : (Element -> Bool)) -> Bool {
		return self.map(f).or
	}
	
	/// Maps a predicate over a list.  For the result to be true, the predicate must be satisfied by
	/// all elemenets of the list.
	public func all(f : (Element -> Bool)) -> Bool {
		return self.map(f).and
	}
}

//extension List where A : Equatable {
//	/// Takes two lists and returns true if the first string is a prefix of the second string.
//	public func isPrefixOf(r : List<A>) -> Bool {
//		switch (self.match, r.match) {
//		case (.Cons(let x, let xs), .Cons(let y, let ys)) where (x == y):
//			return xs.isPrefixOf(ys)
//		case (.Nil, _):
//			return true
//		default:
//			return false
//		}
//	}
//
//	/// Takes two lists and returns true if the first string is a suffix of the second string.
//	public func isSuffixOf(r : List<A>) -> Bool {
//		return self.reverse().isPrefixOf(r.reverse())
//	}
//	
//	/// Takes two lists and returns true if the first string is contained entirely anywhere in the
//	/// second string.
//	public func isInfixOf(r : List<A>) -> Bool {
//		return r.tails.any(self.isPrefixOf)
//	}
//	
//	/// Takes two strings and drops items in the first from the second.  If the first string is not a
//	/// prefix of the second string this function returns Nothing.
//	public func stripPrefix(r : List<A>) -> Optional<List<A>> {
//		switch (self.match, r.match) {
//		case (.Nil, _):
//			return .Some(r)
//		case (.Cons(let x, let xs), .Cons(let y, _)) where x == y:
//			return xs.stripPrefix(xs)
//		default:
//			return .None
//		}
//	}
//	
//	/// Takes two strings and drops items in the first from the end of the second.  If the first
//	/// string is not a suffix of the second string this function returns nothing.
//	public func stripSuffix(r : List<A>) -> Optional<List<A>> {
//		return self.reverse().stripPrefix(r.reverse()).map({ $0.reverse() })
//	}
//	
//	/// Takes a list and groups its arguments into sublists of duplicate elements found next to each
//	/// other.
//	///
//	///     group([0, 1, 1, 2, 3, 3, 4, 5, 6, 7, 7]) == [[0], [1, 1], [2], [3, 3], [4], [5], [6], [7, 7]]
//	public var group : List<List<A>> {
//		return self.groupBy { a in { b in a == b } }
//	}
//}

extension List where A : BooleanType {
	/// Returns the conjunction of a list of Booleans.
	public var and : Bool {
		return self.reduce(true) { $0.boolValue && $1.boolValue }
	}
	
	/// Returns the dijunction of a list of Booleans.
	public var or : Bool {
		return self.reduce(false) { $0.boolValue || $1.boolValue }
	}
}

/// Flattens a list of lists into a single lists.
