Worth a read for some more context.
Create the file in the root of the project (where your Package.swift file lives as well), and use the following contents:
/// Package.xcconfigWorth a read for some more context.
Create the file in the root of the project (where your Package.swift file lives as well), and use the following contents:
/// Package.xcconfig| let elements: [String] = ["A", "B", "C", "D", "E", "F", "G", "H", "I"] | |
| let chunk_1 = elements[...2].joined() | |
| let chunk_2 = elements[3...5].joined() | |
| let chunk_3 = elements[6...].joined() | |
| concat(elements) == chunk_1 <> chunk_2 <> chunk_3 | |
| concat(elements) == concat([chunk_1, chunk_2, chunk_3]) |
| concat(["A", "B", "C"]) == [String](arrayLiteral: "A", "B", "C").reduce("", <>) |
| public func concat<M: Monoid>(_ elements: [M]) -> M { | |
| elements.reduce(.empty, <>) | |
| } |
| extension String: Monoid { | |
| public static let empty: String = "" | |
| } | |
| extension Array: Monoid { | |
| public static var empty: Array { [] } | |
| } |
| // left identity | |
| [] + ["A"] // = ["A"] | |
| // right identity | |
| ["A"] + [] // = ["A"] |
| // left identity | |
| "" + "A" // = "A" | |
| // right identity | |
| "A" + "" // = "A" |
| public protocol Monoid: Semigroup { | |
| static var empty: Self { get } | |
| } |
| XCTAssert( | |
| AssociativeLaw<String>.verify(a: "hello", b: " ", c: "world!") | |
| ) |
| public extension AssociativeLaw where Element: Semigroup { | |
| /// | |
| /// It verifies if the set of elements are **associative** through Semigroup's composition (`<>`). | |
| /// | |
| /// The `<>` operator is used to express associativity in an abstract way. | |
| /// This is because elements can either be associative through *addition* (`+`) or through *multiplication* (`*`). | |
| /// | |
| /// - Parameters: | |
| /// - a: The first semigroup element | |
| /// - b: The second semigroup element |