Sequence and Array

Reminding myself to think outside the map, reduce, and filter boxes.

allSatisfy(_:)

allSatisfy(_:) works like python’s all. Returns true if each and every item in the array passes the given block.

contains(_:) and contains(where:)

contains(_:) is available only if the Element conforms to Equatable. This effectively is the same as calling contains { $0 == element }, though I imagine the implementation is slightly more optimized than that.

contains(where:) works like python’s `any. It takes in a block, and returns true if that block returns true for least one item in the receiving array or sequence.