Avatar
func testReduce() { measure { XCTAssertEqual(ns.reduce(0) { $0 + $1 * $1 }, squareSum) } } func testForLoop() { measure { var result: Int64 = 0 for n in ns { result += n * n } XCTAssertEqual(result, squareSum) } } func testMapReduce() { measure { XCTAssertEqual(ns.map { $0 * $0 }.reduce(0) { $0 + $1 }, squareSum) } } (edited)